Please read all of this before you answer
So far, no exaggeration, I have spent five days of trial and error, without any luck/ progression. I'm trying to make a timer script, Like the one seen in Ozzypigs 'Hunger Games', Please note: I'm not trying to copy his game, just using it as a reference, but so far, here are the problems I have run in to. -- Script not functioning at all- -- Script not registering the IntValue in Workspace- -- Timer resetting when player joins or dies- -- Script getting stuck at certain values- -- Studio crashing/freezing while trying to use scripts-
== As you might be able to see, I have gotten NOWHERE. I am not asking for a script, I know this isn't a request website, but I am asking for help. I am stuck, with nothing left, and I plan to release the game on the 15th, but at this rate, it probably won't happen. For those who answer, Thank you. For those who don't, Thanks anyways.
Info: -[]-The location of the timer is: game.Workspace.StarterGui.TimerSet.Frame.Time.Script -[]- I am trying to create a GUI!!!! - timer that is the SAME FOR EVERYONE, no matter if they reset, or a new player joins, No others reason. Just a timer that runs for 30 seconds, then twelve minutes, then after twelve minutes, kills everyone, then loops. -[]- I need the timer to be on a string so players can see the time left. Thank you. Any further questions, PLEASE comment them. Thanks again!
Well you don't exactly need a IntValue to make a timer script.
game.Workspace.StarterGui.TimerSet.Frame.Time.Script
StarterGui is not a child of workspace, it is the child of the game and will be defined like this
game.StarterGui.TimerSet.Frame.Time.Script
In this case i'll show you an example how I would do it
Let's say there is an order in StarterGui
ScreenGui
Frame
TextLabel
for i,v in pairs(game.Players:GetPlayers()) do Time = 30 -- 30 seconds for i = Time,0,-1 -- It minus 30 by 1(look at wait) , that zero in the middle is that it stop at 0. Time = i v:WaitForDataReady("StarterGui").ScreenGui.Frame.TextLabel.Text = ""..Time -- Get's all the players TextLabel And changes the time!! wait(1) -- For every 1 second it subtracts 1 from Time which is equal to 30. end end
If this helped +1
Ok, there you have your script inside the Gui and an IntValue in your Workspace, called Timer. The Gui has a text label and the time will be set in seconds.
timer = game.Workspace.Timer text = script.Parent.TextLabel -- or wherever it is timer.Changed:connect(function() -- runs everytime the value changes if timer.Value < 60 and timer.Value > 0 then -- if it's less than 1 minute text.Text = tostring(timer.Value) .. " second(s) left" -- turns the value into text elseif timer.Value >= 60 and timer.Value > 0 then -- if it's more than one minute seconds = timer.Value % 60 -- subtracts the minutes and leave the seconds minutes = math.floor(timer.Value / 60) -- takes the minutes text.Text = tostring(minutes) .. " minute(s) and " .. tostring(seconds) .. " second(s) left" -- bring both to text else -- when it's over text.Text = "Game Over!" -- run some function to end the game end end)
Inside the value this simple script:
script.Parent.Value = 120 -- the total time players have, in seconds while true do -- a loop wait(1) -- wait 1 second script.Parent.Value = script.Parent.Value - 1 -- takes one second from the value end
To start counting the time, just enable the script and you're done.
If you need more help: http://wiki.roblox.com/index.php?title=Math http://wiki.roblox.com/index.php?title=String_manipulation http://wiki.roblox.com/index.php?title=String
[Edit]
script.Parent.Value = 30 -- the first 30 seconds while true do -- a loop wait(1) -- wait 1 second script.Parent.Value = script.Parent.Value - 1 end script.Parent.Value = 720 -- the final 12 minutes while true do -- a loop wait(1) -- wait 1 second script.Parent.Value = script.Parent.Value - 1 end