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

My tool is supposed to end the loop sound when unequipped, anybody know how to fix it?

equipped = true
script.Parent.Equipped:connect(function(mouse)
	Looped = true
tool = script.Parent
Handle = tool:WaitForChild'Handle'
sound = Handle:WaitForChild'Sound'

tool.Activated:connect(function()
	sound:Play()
	sound.Looped = true
	equipped = false
	Parent.Unequipped:connect(function()
		sound.Looped = false
	end)
end)
end)

1 answer

✓ Accepted answer

Here, this should be your solution:

local tool = script.Parent
local handle = tool:FindFirstChild("Handle")
local sound = handle:FindFirstChild("Sound")
equipped = false

script.Parent.Equipped:connect(function()
equipped = true
sound.Looped = true
sound:Play()
end)

script.Parent.Unequipped:connect(function()
equipped = false
sound:Stop()
end)

5 comments

0

Thank you!

0

There is actually an error that occured in this script some how and it has to do with the = on the second line where it says handle = tool... I have no idea why but I trust your coding, is there something you could have possibly done wrong?

0

Oh, my bad! Try using this on the 2nd line: local handle = tool:FindFirstChild("Handle"). I accidentally added in 2 equal signs.

0

I'll make sure to edit my answer to fix these typos so you can easily replace it.

0

Thank you, I'm sure it will work very well, it actually does help me alot because I am coding for one of my friends as we are both not very good coders but I am just that much better that he asked me to, and I really appreciate your help, thank you!

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