gum444Join Date: 2011-05-06 Post Count: 549 |
Why does the time stop at 2 if it says until time = 0? Is this a glitch?
function StartRound()
local m = Instance.new("Hint")
m.Parent = game.Workspace
local Time = "10"
repeat
wait(1)
m.Text = "The game will begin in "..Time.." seconds!"
Time = Time - 1
until Time == 0 --This is what I'm talking about!
m.Text = "The round will now begin!"
end
StartRound() |
|
ha_hJoin Date: 2013-05-18 Post Count: 1695 |
add while true do .
yes my siggy |
|
gum444Join Date: 2011-05-06 Post Count: 549 |
Does not work, does same thing
ROBLOX is broken |
|
ha_hJoin Date: 2013-05-18 Post Count: 1695 |
oh wait set time to 4*x and y of the new instance block of z
yes my siggy |
|
|
function StartRound()
local m = Instance.new("Hint")
m.Parent = game.Workspace
for Time=10,0,-1 do
m.Text = "The game will begin in "..Time.." seconds!"
wait(1)
end
m.Text = "The round will now begin!"
end
StartRound() |
|
gum444Join Date: 2011-05-06 Post Count: 549 |
No I don't want a script, Im just saying that this thing is broken and should not stop at 2! |
|
|
function StartRound()
local m = Instance.new("Hint")
m.Parent = game.Workspace
local Time = "10"
repeat
wait(1)
m.Text = "The game will begin in "..Time.." seconds!"
Time = Time - 1
until Time == -1 --This is what I'm talking about!
m.Text = "The round will now begin!"
end
StartRound() |
|
|
It might just be how repeat works, I barely use it though. |
|
gum444Join Date: 2011-05-06 Post Count: 549 |
I did use the -1 value instead of 0. But roblox needs to fix that :/ |
|
|
The problem is with the "Time" variable. Time in your script is a string. You can't do math (like Time = Time - 1) on a string. Strings are used for text. Replace:
local Time = "10"
with
local Time = 10
|
|
|
@filiptibell, Actually, I was going to say the same thing at first but I tested:
print("10"-1)
>9
So Lua must use the tonumber() function on strings if you try doing math on them. |
|
|
You're still right though, it shouldn't be set as a string. |
|
|
Woops. I had no idea, that's kinda unexpected.
The problem was that you had the wait(1) before doing Time = Time - 1. Move it to the end of the repeat statement instead, and it works just fine:
function StartRound()
local m = Instance.new("Hint")
m.Parent = game.Workspace
local Time = 10
repeat
m.Text = "The game will begin in "..Time.." seconds!"
Time = Time - 1
wait(1)
until Time == 0
m.Text = "The round will now begin!"
end
StartRound()
|
|
DaftcubeJoin Date: 2010-01-10 Post Count: 275 |
Using repeat isn't generally considered a good practice, as some other types of loops do its job better. That's what I hear, at least. |
|