Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

3 comments

0

ok thanks! I'll try it out!

0

THANKS! It works!

0

No problem

This discussion is preserved as it was. New answers, comments, and votes are closed.