#How can I make a power system?

2 messages · Page 1 of 1 (latest)

outer mason
#

I made a door and and light script and what I want to achieve is a power system that drains by itself but whenever the door and the light is activated then it decreases faster. I tried using a for do loop to create that but it isn't very reliable because whenever the door or the light activates, the count waits for the current count to go down before it starts draining faster. Plus I can't seem to make it so if the light and the door is open at the same time then the drain decreases even faster. Here the script :

local text = script.Parent
local countdown = 100
local bool = workspace.Billis.FNaFdoor.OpenDoor
local time = 5
local LightBool = workspace.Billis["FNaF light"].OpenLight

for count = -1, 100, 10 do
    if bool.Value == true or LightBool.Value == true then
    countdown -= 1
    text.Text = countdown
        wait(time/2)

    elseif LightBool.Value == true and bool.Value == true then
        countdown -= 1
        text.Text = countdown
        wait(time/4)
    else
        countdown -= 1
        text.Text = countdown
        wait(time)
    end
end
nova island
#

i would just make a while loop that decreases power over time