Saving the Equipped Tool on death

How would I go about saving the player’s tool that they were using right before the players death? My game relies on a custom backpack system
where only one item can be equipped at a time and the game is pvp based so the player is dying a lot. For convenience sake I want to add a script to detect what sword the player is using when they die and automatically equip it when they respawn. Any useful tips? I figure you could just set a variable to whatever the characters holding and then clone it, but i’m not sure the exact syntax.

1 Like

You can get the tool inside (when Humanoid.Died fires) the character and being based on the tools name clone the tool into the player’s backpack

1 Like

Search it up, unless theres nothing that helps

There are also models in the toolbox that help save tools

You could set an Attribute for the player named “Tool” or w/e with the value being the name of the tool you want them to spawn with. Have the tool and other tools in a folder in ReplicatedStorage or ServerStorage and when a character is added, look for the tool name from the player’s Attribute in the folder and clone it into the player’s backpack.

I’m gonna try this thank you for the idea!

Is there a HumanoidRespawn Function or do you think a wait value after the death would accomplish the job.

What do you mean? Trhtycharssss

So first I store the weapon by finding what’s in the character. Now I need to give it to the character when they respawn. Would I just do a PlayerAdded function to know when to give the player they’re item?

No, you just check if player has a tool inside backpack or character when they die, and after getting the name you give em the tool based on that name

just wrote this script, decided to publish it on an unsolved thread. for anyone reading this ur welcome lol

-- put into starter plr scripts
local player = game.Players.LocalPlayer
local toolName = nil

-- Function to equip tool again when respawned
local function respawnEquip()
	if toolName ~= nil then
			if player.Backpack:FindFirstChild(toolName) then
				local t = player.Backpack:FindFirstChild(toolName)

-- Function to listen for tool unequip
local function unequipped(tool)
	if tool.ClassName == "Tool" then
		toolName = tool.Name
--	print(tool.Name)

-- Listen for tool unequip

-- Listen for respawning

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.