Help with giving players a tool

Hello!

I am making a game with a Round System and I want it to be so that when the Round starts, players will recieve a tool cloned from ServerStorage into their backpack, but everytime I try this it wouldn’t work.

I am using a Server script to do this, here is the line of code:

  local cloneTool = game.ServerStorage:WaitForChild(Builder):Clone()
  cloneTool.Parent = player.Backpack

I don’t know what to do

1 Like

Your script doesn’t know what player is, you must either create a variable or parameter first. Try this:

local player = game.Players:GetChildren()
local cloneTool = game.ServerStorage:WaitForChild("Builder"):Clone()
cloneTool.Parent = player.Backpack
1 Like

Quick note to add: game.Players:GetChildren() returns a table of the player instances.
A loop should work for this issue:

local cloneTool = game.ServerStorage:WaitForChild("Builder")

for _, player in pairs(game.Players:GetPlayers()) do
    cloneTool:Clone().Parent = player.Backpack
end 

Hope it helps!

1 Like

Well GetChildren loops through all children in the player service so a for loop with GetPlayers would be the same thing

2 Likes

Yeah, just noticed the issue in my reply after @Dfn150 pointed it out. Thanks.
Apart from that the provided code should work.

1 Like