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?
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)
Hmm, I don't know why but, none of these work! Sorry.
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!
Put this in Local Script. That's why none of these work. You didn't put it on Local Script
I did put it in a localscript.
Oh.. Well...... Are you putting it in a brick?
Oh and..... Do you have a object named "Sword"? It has to have capital.
Fixed it.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
One error you had is you said "BackPack" but it needs to be "Backpack"
Neither of yours work, I don't know what's going on! Wait, is it because it doesn't work in test?