I want to put my table in another separate place so I can grab it with all my other scripts that requires it. It would be much easier just to change only one script instead of many other ones.
local admins = { [43764376] = true;--baxzzi [123268417] = true;--canadian_kidgamer [86489853] = true;--JonathanParkourPro }
This is the table I want to grab and use it as a "local variable" for other scripts to use. Anyone know how to achieve this?
Here's the whole the script that this table is in.
local players = game:GetService('Players') local me = players:GetPlayerFromCharacter(script.Parent) local character = me.Character local head = character:WaitForChild("Head") local nametag = game.ServerStorage:WaitForChild("nameTag") local cloned = nametag:Clone() local type1 = cloned:WaitForChild("type1") local line1 = type1:WaitForChild("line1") local imageFrame = type1:WaitForChild("imageFrame") local rank = imageFrame:WaitForChild("rank") local debug = game.ServerScriptService.debugMode.Value local admins = { [43764376] = true;--baxzzi [123268417] = true;--canadian_kidgamer [86489853] = true;--JonathanParkourPro } cloned.Parent = head cloned.Adornee = head cloned.type1.Visible = true line1.Text = "Player ".."(".. me.name ..")" imageFrame.Visible = true if admins[me.userId] then imageFrame.Size = UDim2.new(0.35,0,0.3,0) imageFrame.Position = UDim2.new(0.32,0,0.3,0) imageFrame.ImageColor3 = Color3.fromRGB(255, 82, 85) rank.Text = "ADMIN" else print('not admin') end
You could use remote events or bindable events. So basically, you make your table variable a tuple argument in your event, and then you send it. When the other script receives it(just in case you don't know, bindable events are for communicating server to server or client to client and remote events are for communicating client to server or server to client, but I will be doing bindable example), the argument (in this case your table) will be passed to the other script, and you can use it. Take your table, for example. I will send your table from a server script to a server script and the script that receives the table will print it's contents. Ready? So first, let's get the bindable event set up. This looks similar to your script, only I add the bindable event. Now you can send your table to another script.
wait(2) local admins = { ["43764376"] = true;--baxzzi ["123268417"] = true;--canadian_kidgamer ["86489853"] = true;--JonathanParkourPro } game.ReplicatedStorage.BindableEvent:Fire(admins)
There! almost done. So just to summarize what I did, I just took your table and made it a tuple argument inside your event. Now, to the other script!
game.ReplicatedStorage.BindableEvent.Event:Connect(function(admins) for Key, Value in pairs(admins) do print(Key) print(Value) wait(1) end end)
So this will wait for the event to be fired, and it will find your table argument and set it to the parameter "admins". It will then iterate through your table until it prints every key and value. Feel free to do whatever you want with the table! You don't have to print it! If you are using client to server or server to client communication, be sure to use a remote event k. I hope this helps. :)