Script doesn't re-equip inventory items when you respawn

I have inventory system in my game. However when you die, all of your equipped items are no longer equipped. I wrote this code to re-equip them when you die but nothing happens at all and my items are still not equipped when I respawn:

LocalPlayer.Character:WaitForChild("Humanoid").Died:Connect(function()
	local equippedTrailValue = dataFolder:WaitForChild("Inventory"):WaitForChild("EquippedItems"):WaitForChild("EquippedTrail")
	local equippedAuraValue = dataFolder:WaitForChild("Inventory"):WaitForChild("EquippedItems"):WaitForChild("EquippedTrail")
	local equippedAccessory1Value = dataFolder:WaitForChild("Inventory"):WaitForChild("EquippedItems"):WaitForChild("EquippedAccessory1")
	local equippedAccessory2Value = dataFolder:WaitForChild("Inventory"):WaitForChild("EquippedItems"):WaitForChild("EquippedAccessory2")
	local equippedAccessory3Value = dataFolder:WaitForChild("Inventory"):WaitForChild("EquippedItems"):WaitForChild("EquippedAccessory3")

	for _, trail in pairs(trailsFolder:GetChildren()) do
		addTrailItemUI(trail)
	end

	for _, aura in pairs(aurasFolder:GetChildren()) do
		addAuraItemUI(aura)
	end

	for _, accessory in pairs(accessoriesFolder:GetChildren()) do
		addAccessoryItemUI(accessory)
	end

	if equippedTrailValue.Value ~= nil then
		equipItemRE:FireServer("Trail", equippedTrailValue.Value.Name)
	end

	if equippedAuraValue.Value ~= nil then
		equipItemRE:FireServer("Aura", equippedAuraValue.Value.Name)
	end

	if equippedAccessory1Value.Value ~= nil then
		equipItemRE:FireServer("Accessory1", equippedAccessory1Value.Value.Name)
	end

	if equippedAccessory2Value.Value ~= nil then
		equipItemRE:FireServer("Accessory2", equippedAccessory2Value.Value.Name)
	end

	if equippedAccessory3Value.Value ~= nil then
		equipItemRE:FireServer("Accessory3", equippedAccessory3Value.Value.Name)
	end

	refreshAllEquippedItems()
end)

2020-06-06 22-35-15.mp4 - Google Drive (apparently the video is too large)

I have tried using LocalPlayer.CharacterAdded:Connect() but it doesn’t even fire…

1 Like

What does the output say?

30 CHARS

Nothing

Hmm…

Probably not the best solution (if it even is a solution) but:

I think you should clone your tools in the inventory when you die, and put them in a folder somewhere.

and did that character added event work only once?

It didn’t work even once.

The item’s don’t disappear from the inventory, they just get unequipped and the inventory gui doesn’t show them anymore.

for the inventory gui thing, is the reset on spawn true? If so, set it to false.

1 Like

Dying does not mean the state of respawning. Also on another topic, they have addressed the issue of why CharacterAdded sometimes fails to fire properly initially.

1 Like