Scripting Error (HELP)

I am trying to make a staff only door that is connected to my group. So basically in my game, there will be a door where only certain ranks in the group are able to join. So for example the ranks are Friends and above. This is the local script im using. (And yes the door is checked for collide)

if not game:IsLoaded() then
game.Loaded:Wait()
end
pcall(function()
if game.Players.LocalPlayer:GetRankInGroup(7063801) >= 99 then
warn(true)
for i,v in pairs(workspace.StaffDoor:GetChildren()) do
v.CanCollide = false
end
end
end)

It wont let me enter the door, what is the mistake?

2 Likes

Try doing warn(tostring(true)) or warn('true'). I don’t think anything aside from a string can be outputted. Also, for future reference, maybe use the code formatting the forum has, and provide an output error if there is one.

For the loop, check if it’s a BasePart, as @codyorr4 said.

for i,v in pairs(workspace.StaffDoor:GetChildren()) do
    if v:IsA('BasePart') then
        v.CanCollide = false
    end
end

any errors in your output? maybe some children of the StaffDoor don’t have a CanCollide property, or its an issue with rank check.

EDIT:

@7z99 you can print values directly. (numbers, booleans, strings, table address etc).
so he doesn’t have to wrap quotes around true.

@ASAP_Gzni i recommend trying 7z99’s method and only handle CanCollide on BaseParts.

1 Like

Also add a if v:IsA (‘UnionOperation’) in case your door also has unions.

I am pretty sure unions fall under BaseParts.

Edit: Yeah, it does. Run this in your command line:

local union = Instance.new("UnionOperation") print(union:IsA('BasePart'))

They do not. A UnionOperation is a separate class for unions.

Edit: I hadn’t seen your edit at the time of this.

1 Like

instead of using >= 99, use > 98

Make sure the localscript is in the clientside