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: Why doesn't this work? it's so basic

Previous Thread :: Next Thread 
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
31 Mar 2015 04:20 PM
value = "-1^(1/2)"
value:gsub ("-1^(1/2)","i")
print (value)
--> -1^(1/2)

Why doesn't it substitute that for i?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
31 Mar 2015 04:25 PM
Because you have to define the gsub, not just the value variable.
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
31 Mar 2015 04:29 PM
What?
Isn't that a valid shortcut for string functions?
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
31 Mar 2015 04:31 PM
You need to escape parentheses with the percent character, and string:gsub() doesn't modify the string, because Lua strings are immutable. It returns a new string. So you need to do value = value:gsub(...)

value = "-1^(1/2)"
value = value:gsub("-1^%(1/2%)", "i")
print(value)
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
31 Mar 2015 04:42 PM
What he said^
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
31 Mar 2015 07:25 PM
That makes sense, but why do I have to escape for parenthesis if the string is in quotes?
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