im making a fnaf power system where there's a tick value that when goes over 100 it goes back to 0 and takes away a bit from the power (in another script), I want to make it that the more stuff you use, the tick goes down faster, I tried to make it but it stayed the same. can someone help me please
local hallwayLight = workspace.HallwayLight["IsHallwayLightUsed?"] local leftDoor = workspace.LeftDoor["IsLeftDoorClosed?"] local leftLight = workspace.LeftDoor["IsLeftDorrLightOn?"] local rightDoor = workspace.RightDoor["IsRightDoorClosed?"] local rightLight = workspace.RightDoor["IsRightDoorLightOn?"] while hallwayLight == true do wait(0.3) script.Parent.Value += 1 end end while leftDoor == true do wait(0.3) script.Parent.Value += 1 end end while leftLight == true do wait(0.3) script.Parent.Value += 1 end end while rightDoor == true do wait(0.3) script.Parent.Value += 1 end end while rightLight == true do wait(0.3) end end
The while loop doesn't constantly check if something equals true, it only checks it at that moment, try using .Changed or something
When you put lines of code after a loop (especially the while
loop), it won't run because the code will get stuck in that loop forever. Maybe you can use break
but I'm not sure if it will only break the loop only or stop the entire script.
Try making one huge loop and inside it, make multiple conditions for each of them that if one of them has a Value
of true (i assume they're all BoolValue
) it will increase the Value
of script.Parent
.
local hallwayLight = workspace.HallwayLight["IsHallwayLightUsed?"] local leftDoor = workspace.LeftDoor["IsLeftDoorClosed?"] local leftLight = workspace.LeftDoor["IsLeftDorrLightOn?"] local rightDoor = workspace.RightDoor["IsRightDoorClosed?"] local rightLight = workspace.RightDoor["IsRightDoorLightOn?"] while true do task.wait(0.3) if hallwayLight.Value == true then script.Parent.Value += 1 end if leftDoor.Value == true then script.Parent.Value += 1 end if leftLight.Value == true then script.Parent.Value += 1 end if rightDoor.Value == true then script.Parent.Value += 1 end if rightLight.Value == true then script.Parent.Value += 1 end end