Im making a fan-game about five nights at freddy's, And im having trouble with the power source, I made a value that tells the script if the the door im using is closed or open, If the door is closed it takes up power, But when i open it and close it again it doesn't take up power anymore! Iv tried many loops and if statements, But it seems it wont work!
pwrNum = script.Parent.Frame.PwrNum Pwr = script.Parent.Frame.power DawrPwrRmv = script.Parent.Frame.DoorOneRmv doorone = game.Workspace.door.Door.OpenClosed while doorone.Value == "Closed" do wait(7) Power = Pwr.Value - DawrPwrRmv.Value pwrNum.Text = Power .. "%" Pwr.Value = Power end
What I would do is a while wait() do loop so that the script is constantly running instead of running once and having the script end, once the parameter is met the loop won’t run again. While wait() do will always run so all you need is an if statement in there before you make the power go down. Hope I helped.