Collision Group in Scripting not Working

Hi, I threw together this script and I am confused as to why it isn’t working. The output has 0 errors.

local PhysicsService = game:GetService("PhysicsService")
local InPlayer = PhysicsService:CreateCollisionGroup("PlayerCollision")
local InPart = PhysicsService:CreateCollisionGroup("PartCollidable")

PhysicsService:SetPartCollisionGroup(script.Parent.Part, "PartCollidable")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		for i,v in pairs(char:GetChildren()) do
			if v:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(v, "PlayerCollision")
				PhysicsService:CollisionGroupSetCollidable("PlayerCollision", "PartCollidable", false)
			end
		end
	end)
end)

All it is doing is setting a collision group to the part, then to all parts in the player model, then setting the collision to false. I’m just not sure why it isn’t working. Thanks - lux

I just tried this myself, and it seems to work fine.
Try using .CharacterAppearanceLoaded instead of .CharacterAdded, perhaps the character is loading a bit too fast.

1 Like

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