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

Why doesn't this line of code clone a sword into a player's starter gear?

game.ServerStorage.Sword:Clone().Parent = game.Players:GetPlayerFromCharacter(part.Parent):WaitForChild("StarterGear")

1 comment

0

Its Backpack not startergear.

1 answer

✓ Accepted answer

No such thing as a StarterGear, its called a Backpack. I find your code looks cleaner if you put that code in two lines. Basically, you make a variable, then Parent it. That's up to you, though. Keep in mind, this script would only work if it's in a .Touched function and the parameter is called part.

Also, something else to keep in mind is that you **cannot **access ServerStorage through a localscript since it's only accessible through the server. In this case, you can use ServerStorage as you aren't using a localscript

game.ServerStorage.Sword:Clone().Parent = game.Players:GetPlayerFromCharacter(part.Parent):WaitForChild("Backpack")

--My way

local clone = game.ServerStorage.Sword:Clone()
clone.Parent = game.Players:GetPlayerFromCharacter(part.Parent):WaitForChild("Backpack")

1 comment

0

Actually, it is a .Touched with part. I was just showing you a snippet. Thanks for the help!

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