Let's suppose a player equipped a tool 'x'. Now when he dies, I want that tool to be equipped again. So that the player does not have to continuously equip the tool every time he dies.

Here is my attempt:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local StarterGear = Player.StarterGear
local Backpack = Player.Backpack
local toolOnDeath = {}
wait(1)

Backpack.ChildRemoved:Connect(function(removedChild)
	if removedChild:IsA("Tool") then
		table.insert(toolOnDeath, removedChild)
	end
end)

Player.CharacterAdded:Connect(function()
	print("CharacterAdded")
	if toolOnDeath ~= nil then
		for i, v in pairs(toolOnDeath) do
			if v:IsA("Tool") then
				print("Tool is going to be equipped now")
				Character.Humanoid:EquipTool(v)
			end
		end
	end
end)

But this does not work. "Tool is going to be equipped now" prints but the humanoid does not equip the tool. Why?

Thanks for any help

3 comments

0

You could just parent the tool to the player's character

0

I think it's because you are using local script?

0

@Spjureeedd I tried that like this inside the CharacterAdded above the humanoid equip tool part: v.Parent = Character. But that does not do anything.