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

How to make an if statement check if something has occured over the course of a set time?

Asked by 3 years ago
Edited 3 years ago

Basically for some reason my RoundSystem script after like 30 or more mins of a server running, itll just stop working, no error, no warning; just stops. Now a script to just stop running, you cant just have it set a server value to like false if it fails cuz its not running in the 1st place. What im looking for is; is there a way that i can have a script, check repeatedly throughout the course of lets say 120 seconds; that if a value still hasnt changed throughout that time; that would be caused by the roundsystem; that it would disable roundsystem & then re-enable roundsystem?

I.e. (This of course wont work but)

local RoundSystem = game.ServerScriptService.2n11RoundSystemScript

RoundSystem.Changed:Connect(function()
wait(120)
if RoundSystem still not .Changed then
RoundSystem.Disabled = true
RoundSystem.Disabled = false
end
end)

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Update 6 days later: Figured it out myself.

Put a NumberValue called lets say ServerIsDed in ServerStorage then make the following script in ServerScriptService:

local DedRound = game.ServerStorage.ServerIsDed
local RoundSystem = game.ServerScriptService.RoundSystem

    while true do
        DedRound.Value = DedRound.Value - 1
        wait (1)
        if DedRound.Value < 0 then
        --Whatever map things need to be reset
        RoundSystem.Disabled = true
        RoundSystem.Disabled = false
        end
    end

Then modify your roundsystem so that DedRound.Value = 100 anytime the script is running; if it stops working; it'll auto reset due to the DedRound script.

Ad

Answer this question