So first of all, my apologies if I have done something pretty stupid, I'm very so new to for loops and of course like other people I try to improve myself. So basically what I tried doing here is, I have a folder in replicated storage, and whenever I add a new tool there and when I play the game, that tool would automatically add to the table I have created, but it does not work could anyone help?
local r = game:GetService("ReplicatedStorage") local tool = r.Saber local tools = {tool.StarterSaber} for i, v in pairs(tools) do if v:IsA("Tool") then wait() table.insert(tools, v) print(tools) end end
You can't insert an object into a table. Only the name. Meaning:
local r = game:GetService("ReplicatedStorage") local tool = r.Saber local tools = {tool.StarterSaber} for i, v in pairs(tools) do if v:IsA("Tool") then wait() table.insert(tools, v.Name) print(tools) end end
Unsure why half of this doesn't work, but I don't recommend all the unneeded variables
local repStorage = game:GetService("ReplicatedStorage") local tools = repStorage:WaitForChild("Saber").StarterSaber or workspace.Folder --incase your directory isnt a thing for i, v in pairs(tools) do if v:IsA("Tool") then table.insert(tools, v) print(tools) end end