Collision Groups Not Working

I’m writing a script to save a player’s access to walk thru doors. The saving works but when I play, I can’t walk thru the doors. Here’s my script, and I do supposedly have access to the doors.

Here are samples of my scripts:

This one creates a collision group for every door, player’s are added to this group, and it is set so objects in this group can’t collide . (Look at line 4)

for i, v in pairs(workspace.PaywallsFolder:GetChildren())do
    physicsService:CreateCollisionGroup(v.Name)
    physicsService:SetPartCollisionGroup(v,v.Name)
    physicsService:CollisionGroupSetCollidable(v.Name,v.Name,false)
end

This one adds the player’s parts to the collision group

function addCharacterToCollisionGroup(char,group)
	for i, part in pairs(char:GetDescendants()) do
		if part:IsA("BasePart") then
			print(part.Name)
			physicsService:SetPartCollisionGroup(part,group)
		end
	end
	char.DescendantAdded:Connect(function(obj)
		if obj:IsA("BasePart") then
			physicsService:SetPartCollisionGroup(obj,group)
		end
	end)
end

This part checks to see if the player has access to the door:

	player.CharacterAdded:Connect(function(char)
		for i, v in pairs(PayWalls:GetDescendants()) do
			if v.Value == true then
				print("Has Been Added")
				local collisionGroup = v.Parent.Name
				addCharacterToCollisionGroup(char,collisionGroup)
			end
		end
	end)

Everything is printing properly but it won’t work. What can I change to make this work?

2 Likes

Solved, don’t know what happened, but I solved it.

1 Like