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 |
|
|
|
| 19 Nov 2013 06:58 PM |
| table.insert(_G.addedPlayers, player) |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|