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

How do I assign my item's parent to my player's backpack?

debounce = true

script.Parent.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild('Humanoid')
	if humanoid ~= nil and debounce then
		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.parent)
		print(player.name)
		hit.Position = Vector3.new(22.176, 1.5, -18.612)
		local sword = game.Workspace.ClassicSword:Clone()
		sword.Parent = game.Players.player.Backpack
		print(sword.parent)
		debounce = false
		
	end
end)

I'm getting lost in the layers, this doesn't seem to work. I try to make a copy of the sword and then assign its parent to the player's backpack. Why doesn't this work?

2 comments

0

What are the outputs of your prints?

0

if it is a local script, you can type: sword.Parent = game.Players.LocalPlayer.Backpack

1 answer

Replace sword.Parent = game.Players.player.Backpack with sword.Parent = player.Backpack

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