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