How do I immediately disable player collisions?

Hello! I want to disable player collisions as soon as they join the game. For now I have this script in my game but the issue is that it takes a few seconds until the collisions are disabled:

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

ps: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
				ps:SetPartCollisionGroup(characterPart, "Players")
			end
		end
	end)
end)

I have 9 spawn locations in my map and the spawn area is quite small:

When 2 players join the game at the same time and they both are spawned at the same spawn location, one of them is going to spawn on the roof. How do I avoid this? Or how do I make it so the player can’t collide as soon as they spawned?

Try adding a invisible brick on the roof (or the specific are that they appear on top of) that teleports the players back to the spawn.

1 Like

This is the problem:

Your script is unnecessarily waiting until the Humanoid is loaded, even though by the time the CharacterAdded event is fired, the humanoid would have already loaded.

Your script should look like

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

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

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		for _, characterPart in pairs(char:GetChildren()) do
			if characterPart:IsA("BasePart") then
				ps:SetPartCollisionGroup(characterPart, "Players")
			end
		end
	end)
end)
4 Likes

Thank you. I still have the same issue though.

PlayerCollision is actually a game setting you can toggle, you can find it in the Settings tab on your home bar and then click on Avatar.

1 Like

But it doesn’t disable the collisions. It only let’s me choose between inner and outer box and I don’t even know what that means.

That’s weird. I use a very similar code and it works for me just fine.

1 Like