Loop tool giving?

So I wanna get 10 tools in total by looping a script, but I have no clue how to get the guns using the loop, any help?

script.Parent.GivePowder.OnServerEvent:Connect(function(player)

for i = 1, 10 do

end

end)

If you want to find the number of tools, simply do:

#Guns
1 Like

To get 10 guns in a loop there are quite a few ways. Ill show you with the way you’re doing it.

Your way

for i = 1, 10 do

end

What you should be doing

-- First we get our tool Instances
local Tool1 = script.Parent
local Tool2 = ect...
--Then we create an array holding the tools.
local ToolsTable = {
Tool1;
Tool2;
Tool3;
Tool4;
Tool5;
Tool6;
Tool7;
Tool8;
Tool9;
Tool10;
} --Array

This will create an array where you hold your tools.

for i = 1, #ToolsTable do

end

Here “i” will be the tool, that’s basically the way to do it with a for i x, y

Another way
Now that we have our tables we can use an in pairs loop

for i,SELECTEDTOOL in pairs(ToolsTable) do
print(SELECTEDTOOL.Name) -- Prints the tools name
end

There are also different ways but I won’t be showing those.