CollisionGroup for players not working?

players.PlayerAdded:Connect(function(player)		
	player.CharacterAdded:Connect(function(char)
		local function setGroup(part)
			if part:IsA("MeshPart") then
				part.CollisionGroup = "Players"
			end
		end
		
		char.ChildAdded:Connect(setGroup)
		
		for i, charPart in pairs(char:GetChildren()) do
			if charPart:IsA("MeshPart") then
				charPart.CollisionGroup = "Players"
			end
		end		
	end)
end)

image

No Errors, Nothing in the output.
It just doesn’t work. :man_shrugging:

I’ve tried setting up the “Player” group through a script aswell, but this didn’t change anything.

What am i doing wrong? Any help is greatly appreciated!

1 Like

Try this, sometimes the body parts won’t be a mesh part and do GetDescendants instead of GetChildren (BaseParts also contain MeshParts)

players.PlayerAdded:Connect(function(player)		
	player.CharacterAdded:Connect(function(char)
		local function setGroup(part)
			if part:IsA("BasePart") then
				part.CollisionGroup = "Players"
			end
		end

		char.DescendantAdded:Connect(setGroup)

		for i, charPart in pairs(char:GetDescendants()) do
			if charPart:IsA("BasePart") then
				charPart.CollisionGroup = "Players"
			end
		end		
	end)
end)
1 Like

this worked. Thank you!

(30 limit)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.