Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a script that clones a tool from serverstorage to your backpack when you spawn?

Ive come up with this:

function onPlayerSpawned(player)
  if player.Name == "Player1" then
    game.ServerStorage.Tool:Clone().Parent = player.Backpack
  end
end
 
game.Players.PlayerAdded:connect(function(player)
  player.CharacterAdded:connect(function()
    onPlayerSpawned(player)
  end)
end)

Doesnt work? How would I fix?

2 answers

Found the problem:

if player.Name == "Player1" then

If your testing in Studio, it would be your username. Not Player1 Also use this:

game:GetService("ServerStorage").Tool:Clone().Parent = player.Backpack

4 comments

0

Still doesn’t work. Where would I put the script? Workspace?

0

Put this script in ServerScriptService

0

ITs in there and still doesn’t work.

0

Are you testing this in a Local Server?

Local scripts don't have access to ServerStorage

game.Players.PlayerAdded:connect(function(player)
  player.CharacterAdded:connect(function()
  if player.Name == "yourusername" then
    game.ServerStorage.Tool:Clone().Parent = player.Backpack
  end
  end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.