Players Can't Collide

Hi, I have a quick question…
I know, I can search for it in YouTube but DevForum is better for me.
I just want to know how to make other players can’t collide with you in game, I’m trying to do script but it’s similar to this

--local script
game.Players.PlayerAdded:Connect(function(p)
    local players = game.Players:GetChildren()
    for i, v in pairs() do
        --etc
    end
end)

And I have a lot of problems with that.

Sorry for my grammar

1 Like

Use PhysicsService’s CollisionGroups for this, Roblox made an article about it

1 Like

you gotta loop through the player character and do some collision group id and something kike that i dont remember but you gotta use PhysicsService

1 Like

Well basically you loop through the characters body parts and add each one to a collision group which that collision group cant collide with other things in that collision group, here is a example of how I did it.

local physicsService = game:GetService("PhysicsService")
physicsService:CollisionGroupSetCollidable("Players", "Players", false) -- makes it so players cant collide with players

local function noCollide(character)
	for _, part in pairs(character:GetChildren()) do
		if part:IsA("BasePart") then
			physicsService:SetPartCollisionGroup(part, "Players")
		end
	end
end

players.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	
	character:WaitForChild("HumanoidRootPart")
	character:WaitForChild("Head")
	character:WaitForChild("Humanoid")
	noCollide(character)
end)
2 Likes

I haven’t used this service yet. Thanks for support.

1 Like