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)
I recommend you actually set the variable "db" to match with it's represented positions. (true, false)
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) db = false 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)