Tool not working after death

So, I made this tool that does all this stuff (it doesn’t need to be explained). What you need to know is when you click any player with the tool equipped, a gui pops up, waits 3 secs, then disappears. The thing is, if you reset your character then try it again, it doesn’t work. How can you fix this?
Script:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local tool = script.Parent


local Frame = game.Players.LocalPlayer.PlayerGui:WaitForChild('ScannerGUI'):WaitForChild('Frame') --Object path to the GUI frame containing the age and rank textboxes.
local groupID = 4796549 --ID of your group.




tool.Activated:Connect(function()
	for _,Target in pairs(game.Players:GetPlayers()) do
		if Mouse.Target:IsDescendantOf(Target.Character) then
			Frame.Visible = true
			Frame.Parent.Backround.Visible = true
			Frame.AccAge.Text = Target.AccountAge
			Frame.RoleInGroup.Text = Target:GetRoleInGroup(groupID)
			Frame.AccName.Text = Target.Name
			local ToolsInBackpack = Target.Backpack:GetChildren()
			local listStr = ""
			Frame.Tools.Text = ""
			for i,v in pairs(ToolsInBackpack) do
				if v:IsA("Tool") then
					print(v.Name)
					Frame.Tools.Text = Frame.Tools.Text..v.Name.."\n"
				end
			end
			wait(3)
			Frame.Visible = false
			Frame.Parent.Backround.Visible = false
		end
	end
end)



-- Make sure they can't use the tool while it is not selected.
tool.Unequipped:Connect(function()
	Frame.Visible = false
	Frame.Parent.Backround.Visible = false
end)

Thanks.

2 Likes

Does the output provide any errors? If so, let me know but you could check if the GUIs resetonspawn button is set to enabled, also if you can, let me know if the tool doesn’t work when clicking on the player or otherwise

I set resetonspawn to false and to true but none work. It does not work when you click.

It’s likely the tools aren’t in the backpack, and you can’t equip them because they don’t exist.

No. You can equip it. But when you click any player it doe not work.

It only works once right? 30chars

No it works multiple times. But if you reset and then try it it doesn’t work.

The issue might be within the Unequipped event, add prints and send photos/videos of the actual game or output. Check UI properties when unequipping.

1 Like