Script only working properly once then breaks

Hi everyone!

  1. What do you want to achieve? I made an item in the shop but I want it not to spawn it in everyones inventory when the round starts.

  2. What is the issue? The script works once but when you die, it wont come back.

  3. What solutions have you tried so far? I added a print but it doesn’t get me anywhere farther as it still prints when it doesn’t put it into my inventory.

My script is below.

game:GetService('Players').PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			wait(5)
			for i,e in pairs(player.OwnedItems:GetChildren()) do		
				e:Clone().Parent = player.Backpack
				print("placed "..e.Name.." into "..player.Name.."'s backpack after death")
			end
		end)
	end)
end)

Thanks!

1 Like

You are giving the player their tool after they have died

1 Like