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 » Scripters
Home Search
 

Re: Number won't turn to string

Previous Thread :: Next Thread 
TheAsianCaucasian is not online. TheAsianCaucasian
Joined: 13 Mar 2014
Total Posts: 16
11 Jun 2015 06:11 PM
print 'Hello world!'
cow = script.Parent
local cow = 69
local sheep = tostring(cow)


cow.Text = "Money: $" .. sheep

Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jun 2015 06:12 PM
Jokes on you, it already is a string!
It's because you redeclared "cow" to be a number instead of script.Parent.

print 'Hello world!'
script.Parent.Text = "Money: $" .. 69;
Report Abuse
TheAsianCaucasian is not online. TheAsianCaucasian
Joined: 13 Mar 2014
Total Posts: 16
11 Jun 2015 06:14 PM
Lol I didn't notice that, thanks!
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
11 Jun 2015 06:14 PM
Cnt Lua will flip out on you for attempting to concatenate a number with a string as a literal.
Report Abuse
Brickagon is not online. Brickagon
Joined: 01 Jun 2015
Total Posts: 366
11 Jun 2015 06:14 PM
yeah you can combine numbers and strings without tostring().
but since you did

cow = (object)
local cow = 69

it caused problems
use unique variable names for different things
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jun 2015 06:15 PM
'Cnt Lua will flip out on you for attempting to concatenate a number with a string as a literal.'
r u ok?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
11 Jun 2015 06:17 PM
I don't think so it's late. I'm pretty sure Lua will still flip out on you for attempting to concatenate the string with the number, since neither are variables.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jun 2015 06:19 PM
It doesn't really matter if they're variables, internally they're both stored the same way (well, locals at least).

local b = "asd".."dsa" and
local a = "asd"; local b = a .. "bsd";

will both load "asd" and "dsa" constants into 2 registers and use the concat instruction.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
11 Jun 2015 06:23 PM
Huh it totally flipped out last time I tried to make it do an implicit conversion without variables like that. Which was aaaaageeessss ago.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jun 2015 06:24 PM
inb4 you accidentally? used your wrapper and wrapped the string or number (or both) and didn't handle it (correctly?) using __concat
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
11 Jun 2015 06:26 PM
Aagesss ago was before I even wrapper. I think I tried to perform arithmetic instead and it didn't do the implicit typecast.

Also my wrapper wouldn't mess with that. No locals without the debug library :(
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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