How would I make a part able to collide with players but not any other part

Hello, I am trying to make a part able to collide with players but not able to collide with any other part.
I tried searching up for a solution but collision groups are very weird and kind of complex to use.

I tried making a collision group named “Players” that contained every part of every player’s character and made it not able to collide with another group named “PlayerBlock” that contained all the parts I want to make collidable with the player only, but that didn’t work, it only worked the other way, meaning it can only collide with other parts that are not a player.

How would I make this?

You made a collision group for player parts then made it not collidable to player blocks which you want to be collidable to the player only?

That’s probably why?

CollisionGroups are a bit weird at first but you’ll get used to it.

you also can create CollisionGroups using a script by using the PhysicsService, as shown below:

local PhysicsService = game:GetService("PhysicsService")

--// Create Collision Groups
PhysicsService:RegisterCollisionGroup("Players")
PhysicsService:RegisterCollisionGroup("PlayerBlock")

--// Set what they can collide with
PhysicsService:CollisionGroupSetCollidable("Players", "PlayerBlock", true) --// Players can collide with PlayerBlock
PhysicsService:CollisionGroupSetCollidable("PlayerBlock", "Default", false) --// PlayerBlock cannot colldie with the Default group (the Default being all of your parts that you haven't set a custom collsion group to)

and to apply these CollisionGroups into parts, you can do the following:

Part.CollisionGroup = "Players"
Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		for Index, Part in pairs(Character:GetDescendants()) do
			if Part:IsA("BasePart") then
				Part.CollisionGroup = "Players"
			end
		end
	end)
end)
1 Like

Thanks so much for helping me!

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