Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I change the CollisionGroupId on a player?

I am working on a project were I need to change the collision group ID. I tried two ways in my scripts but neither are working please help.

game.Players.PlayerAdded:connect(function(player)
	local character = workspace:FindFirstChild(player.Name)
	for i,v in pairs(character:GetChildren()) do
		if v.ClassName == "MeshPart" then
			wait(.01)
			v.CollisionGroupId = 2
		end
	end
end)

and

game.Players.PlayerAdded:connect(function(player)
	for i,v in pairs(player.Character:GetChildren()) do
		if v.ClassName == "MeshPart" then
			wait(.01)
			v.CollisionGroupId = 2
		end
	end
end)

3 comments

0

Read this wiki article about and how to use CollisionGroupId: http://wiki.roblox.com/index.php?title=Collision_Filtering . Also, when you want to access the Player's Character, you would do player.Character, not find their name in the workspace, as there might be another instance of the same name.

0

I used a collision group plugin where all I need to do is change the value of the collision group. When I changed it manually In game it worked though through the script it doesn’t

0

I used a collision group plugin where all I need to do is change the value of the collision group. When I changed it manually In game it worked though through the script it doesn’t

1 answer

Here's an example what i use to remove Player Collision.

--Get the service
local PS = game:GetService("PhysicsService")

--Create group
PS:CreateCollisionGroup("Characters")

--Set collidability with eachother to false.
PS:CollisionGroupSetCollidable("Characters","Characters",false)

--PlayerAdded
game.Players.PlayerAdded:Connect(function(Player)
	--CharacterAdded
	Player.CharacterAdded:Connect(function(Char)
		wait() -- roblox logic
		--Get all the parts in the character
		for _,v in pairs(Char:GetChildren()) do
			if v:IsA("BasePart") then
				--Add the part to the group so it doesnt collide with eachother.
				PS:SetPartCollisionGroup(v,"Characters")
			end
		end
	end)
end)

4 comments

0

I would use that except I just need to change the collisiongroupid number

0

well then on line 19 just do v.CollisionGroupId = int

0

I tried that and it didn't work

0

i personaly don't set the ID of a part, but use the pure script sided PhysicsService, so i can't help you with using the property method you're using.

This discussion is preserved as it was. New answers, comments, and votes are closed.