How would i make a script that would get tools from ReplicatedStorage and put them in the table?
GetChildren
is one of many inherited members of the Instance
base class (see here), which means you can call it on any ROBLOX object. This method will return a table (specifically, an array or list), of all the children inside the object you called it on. Here's an example:
local RepStorage = game:GetService("ReplicatedStorage") -- Get service local RepStorageContents = RepStorage:GetChildren() -- Call GetChildren on service -- Iterate through the contents GetChildren returned, printing out their individual names. for k, v in pairs(RepStorageContents) do print("Index:", k, "Object:", v) end
If you're confused about anything, just leave a comment letting me know; I'll respond as soon as possible.
local Tools = game:GetService('ReplicatedStorage') tools = {} Tools.ChildAdded:connect(function(Child) if Child:IsA("Tool") then table.insert(tools, Child.Name) print('Inserted tool name into table') end end)
NOTE
Another script is required to use this.
wait(1) local tool1 = game.TOOLPLACE local tool2 = game.TOOLPLACE wait(1) tool1.Parent = game:GetService('ReplicatedStorage') tool2.Parent = game:GetService('ReplicatedStorage')
NOTE
Do not put tools in replicated storage.
If this is not what you looked for sorry. And I know there is a easier way of doing this, this is my personal way to go.