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

The "if-then" statement in my script keeps working while it's supposed to not work?

Asked by 3 years ago
Edited 3 years ago

Hello guys,

I have an oxygen generator in my game which is gets broken in random times and you go have to restart it or it'll kick everyone in the server due to "low oxygen."

So the problem is; when you restart the oxygen generator, the other script (the script when you click the "restart" button) sets the specific BoolValue to true but somehow the "if-then" statement (which is supposed to work when the specific BoolValue is false) still works and kicks everyone in the server even the BoolValue is set to true already by another script.

Here's the script: (btw a small note: I'm 100% sure about the value sets to true before the timer finishes counting (wait(60)) but it still keeps kicking people.)

local random = math.random(5,30)
repeat wait()
    wait(random)
    if game.Workspace.OxGenIsOnAction.Value==false then
    wait(0.5)
    game.Workspace.OxGenSound.Broken:Play()
    game.Workspace.OxGenSound.Running:Stop()
    game.Workspace.OxGenErrorL.Script.Disabled=false
    wait(60) --timer
    if game.Workspace.OxGenRestartComplete.Value==false then --the statement that I'm talking about.
    for _,v in pairs(game.Players:GetPlayers()) do
        v:Kick("You're failed to restart the Oxygen Generator and died by low oxygen. Please rejoin to regenerate.")
    end
end
end
until game.Workspace.DisasterHappened.Value==true
script.Disabled=true

Answer this question