Playing and pausing a sound when a tool is equipped & unequipped

Basically, I’m working on making a equipped light source play a sound when equipped and then stop the sound when unequipped.

I thought it would be simple enough to put the sound into a part of the tool, which it was, however, whenever you unequip the tool the sound continues to play where the tool was unequipped.

The code I have is as follows and is placed in the tool as a local script… I’m not sure what I’m doing wrong.

local player = game:GetService("Players").LocalPlayer
local tool = script.Parent
local Sound = script.Parent.Head.Sound.Volume

	print(player.Name.." has equipped a torch.")
	Sound = 0.2

	print(player.Name.." is unequipped a torch.")
	Sound = 0


1 Like

I wouldn’t handle the volume when it comes to stopping or pausing. Just assign Sound at the beginning to script.Parent.Head.Sound and remove the .Volume at the end of it. Then change Sound = 0.2 to Sound:Play() and Sound = 0 to Sound:Pause() or Sound:Stop(). Also, did you get any errors when you got the problem?


I had no errors before in the output, but your solution worked perfectly. Thank you!

1 Like

Noticed that it was already answered, sorry