How can I make sure players’ heads don’t collide with anything on the map? I’m trying to do this because as the head grows, they bump into everything… Current code:
local Players = game:GetService('Players')
local PS = game:GetService("PhysicsService")
PS:CreateCollisionGroup('Heads')
PS:CreateCollisionGroup('Parts')
PS:CollisionGroupSetCollidable('Heads', 'Parts', false)
for i, part in next, workspace:GetDescendants() do
if part:IsA("BasePart") and part.ClassName ~= "Terrain" and part.Name ~= "Baseplate" then
PS:SetPartCollisionGroup(part, 'Parts')
end
end
workspace.DescendantAdded:Connect(function(object)
if object:IsA("BasePart") and object.ClassName ~= "Terrain" and object.Name ~= "Baseplate" then
PS:SetPartCollisionGroup(object, 'Parts')
end
end)
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(chr)
for i,v in next, chr:GetChildren() do
if v.Name == 'Head' then
PS:SetPartCollisionGroup(v, 'Heads')
end
end
end)
end)
Your code would work in a real game situation, but PlayerAdded does not fire in studio because the playeradded event fires before other scripts. Thereroe your playeradded … characteradded code will never fire in studio, leaving your head collidable. Try testing out your code in the game itself instead of studio, because your code seems fine.