I'm trying to make a sound play when you're swimming in water, but when I do it plays it even though it's already playing which makes an unwanted effect.
wait(1)
local P = game.Players.LocalPlayer
local character = workspace:WaitForChild(P.Name)
local s = Instance.new("Sound", P.PlayerGui)
s.SoundId = script.Underwater.SoundId
P.Character.Humanoid.Swimming:Connect(
function()
s:Play()
end
)

5 comments
Wait, so the problem is that the sound already plays when the character isn't swimming, and it plays again when the player starts swimming?
So when you go idle the sound plays like normal, but when you are swimming then it keeps playing over and over starting from the beggingÂ
Try adding an if statement to see if the sound is playing.
just add if s.IsPaused then
Just make a bool and make it false b4 u enter water and true when youre in water lol