I made this really simple script, but it's not working.
local backpack = game.Players.LocalPlayer.BackPack script.Parent.Touched:connect(function() game.Lighting.Sword:Clone(backpack) end)
Help?
You have to set the parent;
game.Lighting.Sword:Clone().Parent = backpack
local backpack = game.Players.LocalPlayer.Backpack script.Parent.Touched:connect(function() modelcopy=game.Lighting.Sword:Clone() modelcopy.Parent=backpack end)
local backpack = game:service("Players").LocalPlayer.Backpack --script.Parent.Touched:connect(function() game:service("Lighting"):FindFirstChild("Sword"):Clone().Parent=backpack --end)
Try this. Make sure you put it in the part that gives the sword.
local sword = game.Lighting.Sword script.Parent.Touched:connect(function(h) local player = game.Players:GetPlayerFromCharacter(h.Parent) -- find the player from the character if (player) then -- a player touched it local clone = sword:Clone() clone.Parent = player.Backpack -- parent the clone to the player's backpack end end)
script.Parent.Touched:connect(function(p) p = game.Players:GetPlayerFromCharacter(p.Parent) if p then game.Lighting.Sword:Clone().Parent = p.Backpack end end)
There you go!