Collision Groups Door won't be set non-collidable

Hi! I am currently making a door that will make any player in a group go through it, however. I am using PhysicsService:SetCollisionGroupCollidable() but it doesn’t allows me to go through that door even though I’m at that group. I used print statements and it does work, but when I try to set them to false, it keeps being true, my script is:

local PhysicsService = game:GetService("PhysicsService")
local PlayersService = game:GetService("Players")

local workers = "Workers"
local doors = "Doors"

PhysicsService:CreateCollisionGroup(doors)
PhysicsService:CreateCollisionGroup(workers)

PhysicsService:SetPartCollisionGroup(workspace.GroupDoor1, doors)
PhysicsService:SetPartCollisionGroup(workspace.GroupDoor2, doors)

local function getPlayerParts(character, group)
	for _, child in ipairs(character:GetChildren()) do
		if child:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(child, group)
		end end
	character.DescendantAdded:Connect(function(descendant)
		if descendant:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(descendant, group)
end end) end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if player:GetRoleInGroup(6160853) ~= "Guest" then
			getPlayerParts(character, workers)
		   end end) end)

PhysicsService:CollisionGroupSetCollidable(doors, workers, false)

if not PhysicsService:CollisionGroupsAreCollidable(doors, workers) then
	print("Collision groups weren't set properly.")
	PhysicsService:CollisionGroupSetCollidable(doors, workers, false)
else
	print("Collision groups are set properly!")
end

I tried removing the if statement that sets the collisions but it doesn’t works.
Edit: For some reason, there is a collision group that appears randomly named “p”, I un-checked it and it did work but not with the others.

1 Like

Hmm. Try changing

player:GetRoleInGroup(6160853) ~= "Guest"

to

player:IsInGroup(6160853) == 1
2 Likes

It’s not that, I removed that line but it still didn’t add me to the collision group. I just found another group so I will see if I can get about it in another script.
Edit: I don’t know how or why but actually that worked, I used player:IsInGroup() == false and it didn’t allow me to go through the door, but I set it to true and it worked! A lot of thanks!

1 Like