how to turn player collision off in roblox studio code example

Example: how to turn off player collision in roblox

local PhysicsService = game:GetService("PhysicsService")
PhysicsService:CreateCollisionGroup("Players")

PhysicsService:CollisionGroupSetCollidable("Players", "Players", false)

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		repeat wait(1) until char:WaitForChild("Humanoid")
		
		for _, characterPart in pairs(char:GetChildren()) do
			if characterPart:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(characterPart, "Players")
			end
		end
	end)
end)

-- Put this in "ServerScriptService"
-- Message me on discord Muppet#6931

Tags:

Lua Example