How do i make my tools unequip on death?

i am trying to make it so when a player dies the player unequips all the tools its holding
i have tried putting this in my lightsabertool but with no effect?

	if script.Parent.Parent:FindFirstChild("Humanoid").Died then
		script.Parent.LightsaberEnabled.Value = false
		remoteEvent2:FireServer()
		script.Parent.Attack1.Enabled = false
		script.Parent.Attack2.Enabled = false
		script.Parent.Attack3.Enabled = false
		script.Parent.Attack4.Enabled = false
		script.Parent["Lightsaber top"].Part.Outer.Enabled = false
		script.Parent["Lightsaber top"].Part.Inner.Enabled = false
		script.Parent.Equippedvalue.Value = false
		script.Parent["Lightsaber ignite"].Enabled = false
		script.Parent.serverignite.Enabled = false
		script.Parent.serverSwoosh.Enabled = false
		script.Parent.serverdisable.Enabled = false
		script.Parent["lightsaber swoosh"].Enabled = false
		script.Parent["Lightsaber Disable"].Enabled = false
		script.Parent["Lightsaber ignite"].Ignite:Stop()
		script.Parent.lightsaberonidle:Stop()
		script.Parent["Lightsaber Disable"].Disable:Stop()
		script.Parent["Lightsaber top"].Part1.Transparency = 1
		script.Parent["Lightsaber top"].Part1.PointLight.Enabled = false
		script.Parent["Lightsaber top"].Part1.ParticleEmitter.Enabled = false
		script.Parent["Lightsaber top"].Part1.Trail.Enabled = false
		script.Parent["Lightsaber top"].Part.Transparency = 1
		script.Parent["Lightsaber top"].Part.PointLight.Enabled = false
		script.Parent["Lightsaber top"].Part.Trail.Enabled = false
		script.Parent["Lightsaber top"].Part.ParticleEmitter.Enabled = false
	end

i need some help on this i dont think its to hard but i cant figure it out rn

I’m a little confused by your request here, tools typically get removed from the player’s inventory once they die. What exactly are you trying to achieve here?

To unequip tools, you can likely just put Humanoid:UnequipTools() inside a Humanoid.Died function

When a humanoid dies just do Humanoid:UnequipTools() and that’ll unequip any equipped tools.

yes well i dont exactly want to let the tools unequip on death i want to disable scripts in the tool when the plr dies if you understand that

If you’re trying to actually disable the scripts within the tool, you could just use a for loop, disabling any scripts within the tool. For example:

local Tool = script.Parent

Tool.Equipped:Connect(function()
	local Humanoid = Tool.Parent.Humanoid
	
	Humanoid.Died:Connect(function()
		for i, v in pairs(Tool:GetChildren()) do
			if v:IsA("Script") or v:IsA("LocalScript") then
				v.Enabled = false
			end
		end
	end)
	
end)
1 Like

it worked :smiley: ty !!! (30 letterssss)

Glad I could help, best of luck to you moving forward with your game. Also, remember to mark the reply as solution so people don’t continue replying in the future :slight_smile:

1 Like

thanks! i will keep updating it :smiley:

1 Like

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