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

How can I make a player keep a tool equipped after he died or respawned?

This is my script as of now but , after the player dies or respawns he loses the tool and has to re-equip it. How do I make that a player keeps the tool equipped that he had equipped before he died or respawned?

local equipped = script.Parent.Parent.Parent.Handler.Equipped
local selected = script.Parent.Parent.Parent.Handler.Selected
local location = script.Parent.Parent.Parent.Handler.Location
local player = game.Players.LocalPlayer
local character = player.Character

script.Parent.MouseButton1Click:connect(function()
	if equipped.Value == nil or equipped.Value ~= selected.Value then -- 
		character.Humanoid:UnequipTools() -- 
		if location.Value == player.Backpack then
			character.Humanoid:EquipTool(selected.Value)
			equipped.Value = selected.Value
			script.Parent.Text = "Unequip"
		end
	else
		character.Humanoid:UnequipTools()
		equipped.Value = nil
		script.Parent.Text = "Equip"
	end
end)

1 answer

✓ Accepted answer
game:GetService('Players').PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			local tool = character:FindFirstChildWhichIsA("Tool")
			if tool then
				local clone = tool:Clone()
				player.CharacterAdded:wait()
				clone.Parent = player.Character
			end
		end)
	end)
end)

This is one way to do it

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