Okay, I have a timer. I am creating game called "Crocodile". In this game one of players becomes "Artist". Guy who drawing words. And all players must guess this word by drawing.
while GameStart == true do TimerMessage = Instance.new("Hint", game.Workspace) TimerMessage.Text = "This game will end in " ..TimerValue.. " seconds" wait(1) TimerValue = TimerValue - 1 TimerMessage:remove() if TimerValue == 0 then GameStart = false IsArtist = false TimerValue = 120 end end
and when value GameStart = false script running this:
while GameStart == false do local MaybeArtist = game.Players:GetChildren() game.Workspace.Paintining.ColorPart.BrickColor = BrickColor.White() game.ServerStorage.Value.Value = BrickColor.White() if #MaybeArtist >= 2 then CoolHint = Instance.new("Hint", game.Workspace) CoolHint.Text = "Choosing player..." local RealArtist = MaybeArtist[math.random(#MaybeArtist)] RealArtist.TeamColor = BrickColor.Red() CoolHint.Text = "Choosed!" RealArtist.Character.Humanoid.Health = 0 GameStart = true IsArtist = true CoolHint:remove() if IsArtist == false then RealArtist.TeamColor = BrickColor.Blue() RealArtist.Character.Humanoid.Health = 0 end end if #MaybeArtist == 1 then SorryHint = Instance.new("Hint", game.Workspace) SorryHint.Text = "Not enough players! Sorry!" wait(1) SorryHint:remove() end wait(5) end
Its works yeah, but one problem. When GameStart becomes true, timer doesnt work. But if i am turned "true" in script, its works. But when script running "true" its doesnt work. Why? Sorry for my bad grammar, its bad. I am not from english countries, i am learning english.
while wait() do while GameStart == true do TimerMessage = Instance.new("Hint", game.Workspace) TimerMessage.Text = "This game will end in " ..TimerValue.. " seconds" wait(1) TimerValue = TimerValue - 1 TimerMessage:remove() if TimerValue == 0 then GameStart = false IsArtist = false TimerValue = 120 end end while GameStart == false do local MaybeArtist = game.Players:GetChildren() game.Workspace.Paintining.ColorPart.BrickColor = BrickColor.White() game.ServerStorage.Value.Value = BrickColor.White() if #MaybeArtist >= 2 then CoolHint = Instance.new("Hint", game.Workspace) CoolHint.Text = "Choosing player..." local RealArtist = MaybeArtist[math.random(#MaybeArtist)] RealArtist.TeamColor = BrickColor.Red() CoolHint.Text = "Choosed!" RealArtist.Character.Humanoid.Health = 0 GameStart = true IsArtist = true CoolHint:remove() if IsArtist == false then RealArtist.TeamColor = BrickColor.Blue() RealArtist.Character.Humanoid.Health = 0 end end if #MaybeArtist == 1 then SorryHint = Instance.new("Hint", game.Workspace) SorryHint.Text = "Not enough players! Sorry!" wait(1) SorryHint:remove() end wait(5) end end
I believe this should fix your problem. What I did was add a While
loop so it continuously goes through the loops, and so when one thing is changed it goes to the other, and so on.
Hope this helped and be sure to +1 and accept answer.
If not, please reply back or EDIT your question with the script and any errors in the output so I can fix it as soon as possible.