Perhaps making the sound a global variable instead of a local one will help?
Not sure if this will work but let me know if it did.
script.Parent.Equipped:Connect(function()
local Hum = script.Parent.Parent:FindFirstChild("Humanoid")
sound = Instance.new("Sound",Hum.Torso)
sound.SoundId = "rbxassetid://9849884556"
sound.Volume = 0.025
sound.Looped = true
sound:Play()
end)
script.Parent.Unequipped:Connect(function()
local Hum = script.Parent.Parent:FindFirstChild("Humanoid")
Sound:Stop() -- or you could use Sound:Destroy() if you want the sound completely gone
end)
Avoid using globals, if you must, declare upvalues/non-locals instead, i.e;
local sound = Instance.new("Sound")
local function onEquipped()
--'sound' is captured by this closure
end
local function onUnequipped()
--'sound' is captured by this closure
end
just do this. I put the unequipped function inside equipped so it knows what sound is.
it just destroys it and this is good so multiple sounds don’t go into your hums torso.
What bloxy said is correct. Here is what the fixed code would look like. If you go into the explorer menu you’ll see that the humanoid does not have a Torso child, but that the Torso is part of the character. The humanoid was not needed in this case.