Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can you Insert/Remove arrays from tables from other scripts?

I'm new to coding ROBLOX Lua in general, but I was wondering if I could use

table.insert
--and
table.remove

on tables from other scripts. Could I, if so, how? This would be helpful information to me. Thanks,

2 answers

You can use the Global array (_G) to share values across threads (script or local script) that are derived from the one that created it.

Here's all about it : http://wiki.roblox.com/index.php?title=Global_function

-- A Normal Script

_G.Array = {x,y,z}
-- Another Normal Script

table.remove(_G.Array,1)
table.insert(_G.Array,#_G.Array + 1, 'a')

wait()

for i,v in pairs(_G.Array) do
	print(i..' : '..v)
end

You can test the script out.

2 comments

0

local scripts have their own _G. which is separate from the server

0

Does not mention the use of [""].

This discussion is preserved as it was. New answers, comments, and votes are closed.