Disable character-character collision but not for their own character?

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.

Any help is greatly appreciated! Thanks!

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

2 Likes

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.

2 Likes

I dont quite understand could you elaborate on that if possible? Ty

1 Like

Also couldn’t I make collision groups on the client and just make it not register itself.

1 Like

Just making a very quick and dirty solution that does this:

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:
oq7guj_93091

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)
1 Like

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?

also I appreciate you taking the time to make all that for me. Ty :slight_smile:

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:

6d0tw_93101

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)
3 Likes

Thank you so much for the help! Greatly appreciated!