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

Wait 100 seconds, but on an event, skips the time?

Asked by 10 years ago

How would I do that? Like this; A (round) script waits 100 seconds, but also there is a InGame boolvalue inside each player, and it constantly checks if only 1 person has that boolvalue, or none, and if either of those are true, skips the rest of the time? I have no idea how I would do this.

0
Edited my post sir. OniiCh_n 410 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

You might need 2 separate scripts, one for waiting 100 seconds, and one for checking if anyone has the boolvalue. This is for timing:

while true do
    if Workspace.Running == true then
        for i = 1, 100 do
            Workspace.Time.Value = i  --Time is a NumberValue. You can use this to have a timer on a GUI or something.
            if Workspace.Running == false then --Running is a BoolValue in the Workspace.
                break end
            wait(1)
        end
        Workspace.Running == false
        else wait(1)  --So an infinite loop doesn't occur.
    end
end

As you can see, I made it so that you can easily add a timer. For checking if the BoolValue in the players is true, put this is a separate script.

while wait(1) do --No Infinite Loops!
    if Workspace.Running == true then
        for i, v in pairs(game.Players:GetChildren()) do --v in pairs is awesome
            Value = v.Character:FindFirstChild("BoolValue") --Making sure there is a BoolValue
            if Value.Value == true then
                Workspace.Running == false
            end
        end
    end
end

These should work! Just make sure you have a BoolValue called "Running" and a NumberValue called "Time" in the Workspace. Comment if you have any issues!

0
Would I put the second one in my round script, and the first in a seperate? systematicaddict 295 — 10y
0
Nevermind my last comment, but on line 3, of the first script, I get the error (not output) just when I paste it in, '=' or 'in' expected near '.' systematicaddict 295 — 10y
0
I edited my post. It should work now! User#348 0 — 10y
Ad
Log in to vote
-1
Answered by
OniiCh_n 410 Moderation Voter
10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

This code sums up how it would be organized... Change your conditions to whatever.

Untested, but just an example.

while boolValue == false do
     if game.Players <= 1 then
          wait()
     else
          boolValue = true
end


if condition then
     wait(100)
elseif boolValue then
      --code
end
0
I don't think that would help. systematicaddict 295 — 10y
0
It is meant to be an example OniiCh_n 410 — 10y

Answer this question