Hello there I am trying to make a door slide open when a certain rank is interacting with it. I tried this code but It didn't worked I tried true and false and it still did not work please help here is my code. Plus the group id is stored in numvalue "L". Sorry about too much lines I just need the group problem fixed.
local MOVE_IN_BY = 0.25 local ROOM_LEFT = 0.35 local WAIT_FOR = 0.2 local TIME_OPEN = 0 local model = script.Parent local door = model.Door door.PrimaryPart = door.Main local doorcf = door.Main.CFrame local doorX = door.Main.Size.x local doorClosed = true local doorMoving = false for _,button in pairs(model:children()) do game.Players.PlayerAdded:Connect(function(Player) if Player:GetRankInGroup(script.Parent.Parent.GroupValues.CoreGroup.ID.L.Value) == 255 then doorMoving = false else doorMoving = true end end) if button.Name == "Button" and button:FindFirstChild("ClickDetector") then button.ClickDetector.MouseClick:connect(function() if doorMoving then return end doorMoving = true if TIME_OPEN == 0 then if doorClosed then for i = 0,MOVE_IN_BY,0.05 do door:SetPrimaryPartCFrame(doorcf*CFrame.new(0,0,-i)) wait() end wait(WAIT_FOR) for i = 0,doorX-ROOM_LEFT,0.05 do door:SetPrimaryPartCFrame(doorcf*CFrame.new(i,0,-MOVE_IN_BY)) wait() end door:SetPrimaryPartCFrame(doorcf*CFrame.new(doorX-ROOM_LEFT,0,-MOVE_IN_BY)) doorClosed = false else for i = doorX-ROOM_LEFT,0,-0.05 do door:SetPrimaryPartCFrame(doorcf*CFrame.new(i,0,-MOVE_IN_BY)) wait() end wait(WAIT_FOR) for i = MOVE_IN_BY,0,-0.05 do door:SetPrimaryPartCFrame(doorcf*CFrame.new(0,0,-i)) wait() end door:SetPrimaryPartCFrame(doorcf) doorClosed = true end else for i = 0,MOVE_IN_BY,0.05 do door:SetPrimaryPartCFrame(doorcf*CFrame.new(0,0,-i)) wait() end wait(WAIT_FOR) for i = 0,doorX-ROOM_LEFT,0.05 do door:SetPrimaryPartCFrame(doorcf*CFrame.new(i,0,-MOVE_IN_BY)) wait() end door:SetPrimaryPartCFrame(doorcf*CFrame.new(doorX-ROOM_LEFT,0,-MOVE_IN_BY)) wait(TIME_OPEN) for i = doorX-ROOM_LEFT,0,-0.05 do door:SetPrimaryPartCFrame(doorcf*CFrame.new(i,0,-MOVE_IN_BY)) wait() end wait(WAIT_FOR) for i = MOVE_IN_BY,0,-0.05 do door:SetPrimaryPartCFrame(doorcf*CFrame.new(0,0,-i)) wait() end door:SetPrimaryPartCFrame(doorcf) end doorMoving = false end) end end