Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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
0
Still doesn’t work. Where would I put the script? Workspace? RynKatze 32 — 6y
0
Put this script in ServerScriptService MRbraveDragon 374 — 6y
0
ITs in there and still doesn’t work. RynKatze 32 — 6y
0
Are you testing this in a Local Server? MRbraveDragon 374 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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)

Answer this question