Code:
Ready1 = true Ready2 = false script.Parent.Touched:Connect(function(hit) local h = hit.Parent:FindFirstChild("Humanoid") if h and Ready1 == true then Ready1 = false local folder = game.Workspace.Ambient for i,v in pairs(folder:GetChildren()) do v:Stop() if v.Name == "Wolf" then v.Script.Disabled = true end Ready2 = true end end end) script.Parent.TouchEnded:Connect(function(hit) local h = hit.Parent:FindFirstChild("Humanoid") if h and Ready2 == true then wait(3) Ready2 = false local folder = game.Workspace.Ambient for i,v in pairs(folder:GetChildren()) do v:Play() if v.Name == "Wolf" then v.Script.Disabled = false end Ready1 = true end end end)
Basically, when the player touches a part, audio stops playing. When he leaves the part the audio plays again. Simple right? It works correctly but whenever I stand still or move around the audio plays for a second then stops?