local Giver = script.Parent
local Gear = script.Parent.Tool
function onTouch(Brick)
local Player = Brick.Parent:findFirstChild("Humanoid")
if (Player~= nil) then
local Location = game:GetService('Players')
local New = Gear:Clone()
New.Parent = Location.Backpack --Problem is on this line
end
end
Giver.Touched:connect(onTouch)
✓ ANSWER ACCEPTED
Giver relocating to backpack isn't working?
1 answer
✓ Accepted answer
local Giver = script.Parent
local Gear = script.Parent.Tool
function onTouch(Brick)
local Player = Game.Players:GetPlayerFromCharacter(Brick.Parent) --Get the player from the hit,
if Player and not Player.Backpack:FindFirstChild(Gear.Name) then
local New = Gear:Clone()
New.Parent = Player.Backpack
end
end
Giver.Touched:connect(onTouch)
This discussion is preserved as it was. New answers, comments, and votes are closed.
