title basically explains itself but pretty much I have a script that disables player collision with collision groups but it causes issues as my game includes ragdolling. When a player ragdolls their body parts clip through their torso which is something I obviously dont want. This issue is caused by the fact that when character-character collision is disabled their own character is in the collision group.
i dont know much about collision groups but how about making a unique collision group for each player, then another collision group for everything else.
make each player group collide with the everything else group, but not with eachother. i think that would fix your issue
This requires just 2 collision groups. One group for players, which wont collide with itself, and another for ragdolls which will collide with itself. When the player ragdolls (however you choose to do that), set the parts to the ragdoll group and when they aren’t a ragdoll, set it to the player group.
Which is what it sounds like you want, as you can see I don’t collide with the player, but I do collide with other parts, and when I reset my parts collide with each other again.
This is what my collision groups look like:
And here’s the very hastily done code that resides in ServerScriptService:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
for i, v in ipairs(char:GetDescendants()) do
if not v:IsA("BasePart") then continue end
game.PhysicsService:SetPartCollisionGroup(v, "Players")
end
char.Humanoid.HealthChanged:Connect(function(new)
if new <= 0 then
for i, v in ipairs(char:GetDescendants()) do
if not v:IsA("BasePart") then continue end
game.PhysicsService:SetPartCollisionGroup(v, "Default")
end
end
end)
end)
end)
Wouldn’t that mean others can interact with ragdolls as well and not just yourself?
The way the game works unfortunately its best to make sure players cannot collide with eachother at all times.
Can’t I just use a local script so the collision groups are on the client and make it so it doesn’t count itself?
Well if you do it all on the client then players will still collide with each other. This happens because the one client doesn’t recognize the other client’s change to the collision groups. And if you change all players on the one players local computer that’s the exact same as making the change from the server. Also, if you don’t do it from the server, you might have other issues like characters colliding on the server, but not on their respective clients.
If you want the functionality you’re looking for, I’d introduce a third group and make that collide with itself but not players. Like so:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
for i, v in ipairs(char:GetDescendants()) do
if not v:IsA("BasePart") then continue end
game.PhysicsService:SetPartCollisionGroup(v, "Players")
end
char.Humanoid.HealthChanged:Connect(function(new)
if new <= 0 then
for i, v in ipairs(char:GetDescendants()) do
if not v:IsA("BasePart") then continue end
game.PhysicsService:SetPartCollisionGroup(v, "Ragdolls")
end
end
end)
end)
end)