Audio not turning off.The audio does not turn off when the player steps off the part

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.

You would use a TouchEnded event which will fire some code once the player steps off the part.

Part.TouchEnded:Connect(function()
    -- Further code will stop the audio from playing once player steps off of part
end)

Using TouchedEvent for this is an issue, because the touchEnded event will still fire even tho the player is on the part. I suggest u to use OverlapParams instead to check if player is still on the part