I have been working on a recent project and I need to clone the tool called “Wall” from ServerStorage to StarterPack 5 seconds after the player joins. This is the easiest way I’ve found to give the player a tool, but the script to clone it from ServerStorage to StarterPack isn’t working.
This is my current code in Server Script Service that doesn’t work
local wall = game.ReplicatedStorage:WaitForChild(“Wall”)
local Player = game.Players:GetPlayers()
local CLONE = wall:Clone() – Make a variable
CLONE.Parent = Player.StarterGear
game.Players.PlayerAdded:Connect(function()--fires when a player joins the game
local CLONE = wall:Clone() – Make a variable
CLONE.Parent = Player.StarterGear
end)
Using the .PlayerAdded() event from the Players service, we can accomplish this.
Code
game:GetService("Players").PlayerAdded:Connect(function(player)
wait(5)
local Backpack = player:WaitForChild("Backpack")
local ToolToClone = game:GetService("ServerStorage"):WaitForChild("Wall")
if ToolToClone and Backpack then
ToolToClone:Clone().Parent = Backpack
end
end)