Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

1 comment

0

Edited my post sir.

2 answers

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!

3 comments

0

Would I put the second one in my round script, and the first in a seperate?

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 '.'

0

I edited my post. It should work now!

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

2 comments

0

I don't think that would help.

0

It is meant to be an example

This discussion is preserved as it was. New answers, comments, and votes are closed.