Forced Tool Re-Equip help

Hey everyone,

I’ve been working on a local script thats inside a tool and re-equips said tool whenever the player unequips it. The script itself works fine when a tool is added directly to the players backpack and a tool is unequipped. The problem I’ve ran into is that when players respawn and get their tools back via starter gear the script just deletes the tool from the players inventory when unequipped and I have no idea why.

This is how the script is suppose to function ( Works fine when tool is put straight into backpack, The tool is re-equipping itself while I keep trying to unequip it)

This is how the script functions when a player respawns and gets the tool re-added via starter gear. The Tool vanishes from my backpack after unequipping

I’m absolutely stumped and would appreciate some pointers, I’ve also included the script in question below.

local plr = game.Players.LocalPlayer
local Character = plr.Character or plr.CharacterAdded:Wait()
local Hum = Character:WaitForChild("Humanoid")
local Tool = (plr.Backpack.StormTomeI)
Tool.Unequipped:Connect(function()
	wait(0.5)
	Hum:EquipTool(Tool)
end)

It’s possible your Character and Hum variables refer to the old character. You may want to consider not making them variables.

local Tool = script.Parent --is this correct? This is easier than accessing the tool via the player's backpack.
Tool.Unequipped:Connect(function()
    wait(0.5)
    local character = game.Players.LocalPlayer.Character.Humanoid:EquipTool(Tool);
end);

If you want to test my theory, you could also put some print statements in:

local plr = game.Players.LocalPlayer
local Character = plr.Character or plr.CharacterAdded:Wait()
local Hum = Character:WaitForChild("Humanoid")
local Tool = (plr.Backpack.StormTomeI)
Tool.Unequipped:Connect(function()
	wait(0.5)
	Hum:EquipTool(Tool)
	print("Character: ", Character:GetFullName())
	print("Hum: ", Hum:GetFullName())
end)
1 Like

I switched Tool variable to script.parent and also gave your theory a test but the results were the same. It works fine when i first get the tool but after resetting the character the tool vanishes once again.

local plr = game.Players.LocalPlayer
local Character = plr.Character or plr.CharacterAdded:Wait()
local Hum = Character:WaitForChild("Humanoid")
local Tool = script.Parent
Tool.Unequipped:Connect(function()
	wait(0.5)
	Hum:EquipTool(Tool)
	print("Character: ", Character:GetFullName())
	print("Hum: ", Hum:GetFullName())
end)

What did the print statements print?

You may also want to rename each tool to be unique so you can print the name of the tool & make sure a new one is actually spawned.

I’d say keep peppering more print statements in until you find out what the values are for Tool & Hum, and whether or not the LocalScript that’s running is the LocalScript you’re expecting should be running.

I’d also guess this is the problem, im guessing the local script runs while being in startergear/startertools dk what the one in your player is called.

When working normally it states

14:40:01.501  Character:  Workspace.TheRogueCreator  -  Client - LocalScript:8
14:40:01.501  Hum:  Workspace.TheRogueCreator.Humanoid  -  Client - LocalScript:9

After resetting and getting the tool back via starter gear it states this

 14:43:31.942  Character:  TheRogueCreator  -  Studio
 14:43:31.943  Hum:  TheRogueCreator.Humanoid  -  Studio