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

How to check if a tool is unequiped?

So basically I have a minor problem with my tool. When it's clicked, it will plasy a sound, and stops an idle sound, wait 7 seconds, then play the idle sound. The problem I'm having is that the idle sound stops when its unequipped, then 7 seconds later it plays again while the tool is still unequipped. I'm not sure how to check if the tool is unequipped then stop the sound, because it stops but only for 7 seconds then continues to play. here is the script if needed.

local spell = script.Parent
spell.Equipped:Connect (function()
	spell.Handle.shieldidle.Looped = true
	spell.Handle.shieldidle:Play()
	spell.Handle.Equip.Pitch = 0.8
	spell.Handle.Equip:Play()
end)



local debounce = false
spell.Activated:Connect (function()
	if debounce then return end
	debounce = true
	spell.Handle.light.Brightness = 2
	spell.Handle.shield:Play()
	spell.Handle.shieldidle:Stop()
	wait(7.4)
	spell.Handle.light.Brightness = 1
	spell.Handle.shieldidle:Play()
	debounce = false
end)



spell.Unequipped:Connect(function()
	spell.Handle.shieldidle:Stop()
	spell.Handle.away:Play()
	spell.Handle.shield:Stop()
end)

1 answer

✓ Accepted answer

Use this where you want to check if the script is in the tool:

if script.Parent.Parent.Name == "Backpack" then
	--stuff here
end

you may want to add a loop to check. Happy to help, b_mni.

1 comment

0

Thanks a lot! saved me a lot of trouble

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