I would like me to be able to close the door using the ‘Closedoor’ command
The only problem is that after the ‘elseif’ in my script everything stops working and the ‘Closedoor’ command does not work.
I tried adding and subtracting ‘end’ and tried splitting the commands into two scripts however this makes me only able to open the door once and only once close it after this nothing works anymore even I can’t open it anymore. I couldn’t find any topics on this subject.
local GroupId = 5243321
local MinimumRank = 254
local adornee = false
local open = false
local ticks = script.Tick.Value
local modelleft = script.Parent.Left
local modelright = script.Parent.Right
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Player:GetRankInGroup(GroupId) >= MinimumRank then
if Message == "Opendoor" then
print("Activated")
if adornee == false then
if open == false then
adornee = true
print("not open")
while true do
print(ticks)
wait(0.02)
print("Opening door")
local doneR
local doneL
modelleft:SetPrimaryPartCFrame(modelleft:GetPrimaryPartCFrame() * CFrame.new(0,0,-0.1))
modelright:SetPrimaryPartCFrame(modelright:GetPrimaryPartCFrame() * CFrame.new(0,0,0.1))
if ticks == 230 then
ticks = 0
open = true
adornee = false
break
else
ticks = ticks + 1
end end
elseif Message == "Closedoor" then
adornee = true
while true do
wait(0.02)
print("Closing door")
local doneR
local doneL
modelleft:SetPrimaryPartCFrame(modelleft:GetPrimaryPartCFrame() * CFrame.new(0,0,0.1))
modelright:SetPrimaryPartCFrame(modelright:GetPrimaryPartCFrame() * CFrame.new(0,0,-0.1))
if ticks == 230 then
ticks = 0
open = false
adornee = false
break
else
ticks = ticks + 1
end
end
end
end
end
end
end)
end)