Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

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.

0
local scripts have their own _G. which is separate from the server theCJarmy7 1293 — 6y
0
Does not mention the use of [""]. iRexBot 147 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Thank you for the help.

Answer this question