Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
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

Log in to vote
0
Answered by
Tokyo7979 131
5 years ago
Edited 5 years ago

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)
0
Thank you! satrasatra 8 — 5y
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? satrasatra 8 — 5y
0
Oh, my bad! Try using this on the 2nd line: local handle = tool:FindFirstChild("Handle"). I accidentally added in 2 equal signs. Tokyo7979 131 — 5y
0
I'll make sure to edit my answer to fix these typos so you can easily replace it. Tokyo7979 131 — 5y
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! satrasatra 8 — 5y
Ad

Answer this question