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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Script erroring

Previous Thread :: Next Thread 
devUUIdiot is not online. devUUIdiot
Joined: 18 Dec 2013
Total Posts: 122
27 Dec 2013 07:14 PM
My RBX.Lua script is giving me errors (obviously, why else would I be here?) and I can't figure out what's wrong, it's giving me a stupid stack overflow.

Script (no, it's not a local script though it shouldn't even matter)
_G=setmetatable({},{
__index = function(self, index) return self[index:lower()] end,
__call = function(self, ...) local arguments = {...} table.foreach(arguments, function(index, value) if type(getfenv(0)[value]) == "function" or type(getfenv(0)[value] == "thread" then getfenv(0)[value](self) end end) end
})

Whenever I index it, it gives me it. Is there a reason?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Dec 2013 07:16 PM
Yes, you are just re-invoking the __index metamethod every time.

return rawget(self, index:lower())
Report Abuse
devUUIdiot is not online. devUUIdiot
Joined: 18 Dec 2013
Total Posts: 122
27 Dec 2013 07:18 PM
It worked.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Dec 2013 07:25 PM
You're welcome
Report Abuse
Clayguy247 is not online. Clayguy247
Joined: 03 Sep 2008
Total Posts: 3394
27 Dec 2013 07:27 PM
Why are you using table.foreach instead of pairs?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Dec 2013 07:29 PM
I don't know why he is, but it's deprecated.
I guess it's faster to type?
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