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

Trying to copy tool into players backpack but getting error?

I am trying to copy a tool in ReplicatedStorage into the players backpack when they touch the parent of the script which right now is just a normal part but I am getting the error Backpack is not a valid member of MeshPart and I don't know why. Here is the code:

function touch(hit)
	local copy = game.ReplicatedStorage:FindFirstChild("Tool")
	copy:Clone()
	local hum = hit.Parent:FindFirstChild("Humanoid")
	if hum~=nil then
		copy.Parent = hit.Backpack
		print("Tool Given")
	end
end
script.Parent.Touched:Connect(touch)

1 answer

✓ Accepted answer

You are trying to copy the tool into the hit itself, instead of player backpack so what you would need to do is

copy.Parent = game.Players:FindFirstChild(hit.Parent.Name).Backpack

This discussion is preserved as it was. New answers, comments, and votes are closed.