Local script. Inside StarterPlayerScripts
local playing = false
local sound = workspace.Folder.Sounds:WaitForChild("BaseSound")
workspace.Folder.Obby.Start:WaitForChild("BaseStart").Touched:Connect(function(hit)
if hit.Parent and hit.Parent:FindFirstChild("Humanoid") and not playing then
playing = true
print("Playing sound")
sound:Play()
sound.Ended:Wait()
playing = false
end
end)
workspace.Folder.Obby.Start.BasePart.HumanoidExited:Connect(function(hit)
if hit.Parent and hit.Parent:FindFirstChild("Humanoid") and playing then
playing = false
print("Stopping sound")
sound:Stop()
end
end)
The audio does not turn off when the player steps off the part.