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

How to properly subtract...?

Asked by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

By this time, I've done everything that I could think of. For a game that I'm developing, I'm making a timer script for the Intermission. I remembered that somebody could join in-between, and they wouldn't see the GUI, so I tried to make it happen. In the GUI, it has a while loop that makes the text the value of the IntValue. This works perfectly fine in 'Play Solo', just not in a server. Any tips?

while true do
    wait()
    if game.Workspace.Timers.Value == true then -- I have a script that does this and it works fine.
        game.Workspace.Timers.Value = false
        for i=1,30 do
        game.Workspace.Time.Value = game.Workspace.Time.Value - 1
        wait(1)
        end
        for i,v in pairs(game.Players:GetChildren()) do
            v.PlayerGui.Intermission:Destroy()
        end
        game.StarterGui.Intermission:Destroy()
    end
    wait()
end

1 answer

Log in to vote
1
Answered by
TofuBytes 500 Moderation Voter
9 years ago

I tested it and changed :GetChildren() to :GetPlayers() which may be the case. As well as changing the variable you put for players to _ in-case it was a variable problem. Nothing else seemed to be broken after that.

while true do
    wait()
    if game.Workspace.Timers.Value == true then
        game.Workspace.Timers.Value = false
        for i=1,30 do
        game.Workspace.Time.Value = game.Workspace.Time.Value - 1
        wait(1)
        end
        for _,v in pairs(game.Players:GetPlayers()) do
            v.PlayerGui.Intermission:Destroy()
        end
        game.StarterGui.Intermission:Destroy()
    end
    wait()
end
0
It wasn't the case, but this did lead me to thinking how to resolve the problem. It wasn't much in this script, but another script. +1 for taking your time away. Shawnyg 4330 — 9y
Ad

Answer this question