Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I am trying to make a power source that doors need to open and close,Help?

Asked by 7 years ago

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

1 answer

Log in to vote
1
Answered by 7 years ago

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.

0
ok thanks! I'll try it out! mokrane100 4 — 7y
0
THANKS! It works! mokrane100 4 — 7y
0
No problem cmgtotalyawesome 1418 — 7y
Ad

Answer this question