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
 

Table Help

Previous Thread :: Next Thread 
Cizox is not online. Cizox
Joined: 25 Dec 2009
Total Posts: 42220
19 Nov 2013 06:56 PM
_G.addedPlayers = {}

function addName(hit)
local player = Game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player ~= nil then
table.insert(addedPlayers, player)
end
end

script.Parent.Touched:connect(addName)

OUTPUT
19:53:51.356 - Workspace.Touch To Add Name To Table.AddButton.AddPlayer:6: bad argument #1 to 'insert' (table expected, got nil)
19:53:51.387 - Script 'Workspace.Touch To Add Name To Table.AddButton.AddPlayer', Line 6
19:53:51.389 - stack end

Any help?
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
19 Nov 2013 06:58 PM
table.insert(_G.addedPlayers, player)
Report Abuse
Cizox is not online. Cizox
Joined: 25 Dec 2009
Total Posts: 42220
19 Nov 2013 07:02 PM
So even if it's global, you have to write the entire variable?
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
19 Nov 2013 07:08 PM
_G does not make the variable global.

_G is a table that can be accessed from any script(Well limited to client or server)

So putting something in _G just puts it in that table...

You could put this at the top of your script to avoid writing _G before it.
--(Might have errors)--


local Old = getfenv()
setfenv(1,setmetatable(_G,{__index = Old}))
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