Hi, i'm scripting a moving door when you interact with a proximityprompt but it only works once.
db = true
script.Parent.ProximityPrompt.Triggered:Connect(function(player)
local character = player.Character
if character:WaitForChild("CurrentRobbery").Value == "Museum" and db == true then
db = false
script.Parent.ProximityPrompt.Enabled = false
script.Parent.BrickColor = BrickColor.new("Lime green")
local door = script.Parent.Parent.Parent.Door
while wait() do
if door.Position.Y <= 30.94 then
door.Position = door.Position + Vector3.new(0,0.1,0)
elseif door.Position.Y == 30.94 then
break
else
wait(10)
while wait() do
if door.Position.Y >= 12.44 then
door.Position = door.Position - Vector3.new(0,0.1,0)
elseif door.Position.Y == 12.34 then
db = true
script.Parent.ProximityPrompt.Enabled = true
script.Parent.BrickColor = BrickColor.new("Really red")
break
end
end
end
end
end
end)

2 comments
In case you are wondering, the positions are just fine.
make db into true when the door finishes opening