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

Giver relocating to backpack isn't working?

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)

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.