generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How Could I Adjust This?

Previous Thread :: Next Thread 
russellthesnake is not online. russellthesnake
Joined: 24 May 2011
Total Posts: 410
19 Jun 2014 05:09 PM
--Variables
local timeAmount = 10
local player = game.Players.LocalPlayer
local timer = player.PlayerGui.ToFTray.Timer.Time

--Change time
for i = timeAmount, 0, -1 do
timer.Text = i
wait(1)
end

--Go red if the time is under 6
if timer.Text <= 5 then
timer.TextColor3 = Color3.new(172/255,0,0)
end

I cannot compare strings (timer.Text) with numbers (5).. so how could I make this work?
Thanks!


"I can't change the direction of the wind, but I can adjust my sails to always reach my destination."
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
19 Jun 2014 05:10 PM
tonumber()
tostring()
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
19 Jun 2014 05:11 PM
So for example

tonumber(timer.Text)
Report Abuse
russellthesnake is not online. russellthesnake
Joined: 24 May 2011
Total Posts: 410
19 Jun 2014 05:13 PM
Thanks, but this doesnt work...

--Variables
local timeAmount = 10
local player = game.Players.LocalPlayer
local timer = player.PlayerGui.ToFTray.Timer.Time
local timeNum = tonumber(timer.Text)

--Change time
for i = timeAmount, 0, -1 do
    timer.Text = i
    wait(1)
end

--Go red if the time is under 6
if timeNum <= 5 then
    timer.TextColor3 = Color3.new(172/255,0,0)
end
Report Abuse
russellthesnake is not online. russellthesnake
Joined: 24 May 2011
Total Posts: 410
19 Jun 2014 05:16 PM
Anybody?
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:17 PM
timeNum doesn't change unless you tell it to.
Change your loop.
Report Abuse
russellthesnake is not online. russellthesnake
Joined: 24 May 2011
Total Posts: 410
19 Jun 2014 05:17 PM
--Variables
local timeAmount = 10
local player = game.Players.LocalPlayer
local timer = player.PlayerGui.ToFTray.Timer.Time

--Change time
for i = timeAmount, 0, -1 do
    timer.Text = i
    wait(1)
end

--Go red if the time is under 6
if tonumber(timer.Text) <= 5 then
    timer.TextColor3 = Color3.new(172/255,0,0)
end


Doesnt work
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:18 PM
Also, that if statement wont be reached until the loop has stopped. You should put it in the loop itself and remove the timeNum variable.
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
19 Jun 2014 05:18 PM
Thanks, but this doesnt work...

--Variables
local timeAmount = 10
local player = game.Players.LocalPlayer
local timer = player.PlayerGui.ToFTray.Timer.Time


--Change time
for i = timeAmount, 0, -1 do
timer.Text = i
wait(1)
end

--Go red if the time is under 6
local timeNum = tonumber(timer.Text)
if timeNum <= 5 then
timer.TextColor3 = Color3.new(172/255,0,0)
end
Report Abuse
russellthesnake is not online. russellthesnake
Joined: 24 May 2011
Total Posts: 410
19 Jun 2014 05:20 PM
I know I probably sound stupid but

What in the loop do i change :P
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:20 PM
@smiley: You just made it run slightly slower. No need to create a local variable which you use once then abandon :P
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:22 PM
Shove the if statement (with adjustments) in the loop!


local timeAmount = 10
local player = game.Players.LocalPlayer
local timer = player.PlayerGui.ToFTray.Timer.Time


--Change time
for i = timeAmount, 0, -1 do
timer.Text = i
if timeAmount <= 5 then --Your
timer.TextColor3 = Color3.new(172/255,0,0) --If
end --Statement
wait(1)
end
Report Abuse
russellthesnake is not online. russellthesnake
Joined: 24 May 2011
Total Posts: 410
19 Jun 2014 06:08 PM
It doesnt change colour
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 06:08 PM
Sorry, brain failed.

if i <= 5 then
Report Abuse
russellthesnake is not online. russellthesnake
Joined: 24 May 2011
Total Posts: 410
19 Jun 2014 06:11 PM
THANKS
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image