m1=script.Parent.StartHorn m2=script.Parent.HornSound m3=script.Parent.EndHorn m1:Stop()m2:Stop()m3:Stop()m1.Volume=0 m2.Volume=0 m3.Volume=0 m2.Looped=false m2.Playing=false;(script.Parent.Parent:WaitForChild("\068\114\105\118\101")).Locotrol.Event:connect(function(d)if d.Horn==true then m2.Volume=0 m2.Looped=false m2:Stop()m2.Playing=false m3.Volume=0 m3:stop()m1.Volume=1 m1:Play()if m1.TimePosition<m1.TimeLength then m2.Looped=true m2.Volume=1 m2:Play()else m1.Volume=0 m1:Stop()end elseif d.Horn==false then m1.Volume=0 m1:Stop()m2.Volume=0 m2:Stop()m2.Looped=false m2.Playing=false m3.Volume=1 m3:Play()end end)
--Horn Sound Code, Metrotren
m1 = script.Parent.StartHorn
m2 = script.Parent.HornSound
m3 = script.Parent.EndHorn
m1:Stop() --Initial setup
m2:Stop()
m3:Stop()
m1.Volume = 0
m2.Volume = 0
m3.Volume = 0
m2.Looped = false
m2.Playing = false
script.Parent.Parent:WaitForChild("Drive").Locotrol.Event:connect(function(data)
	if data["Horn"] == true then
		m2.Volume = 0
		m2.Looped = false
		m2:Stop()
		m2.Playing = false
		m3.Volume = 0
		m3:stop()
		m1.Volume = 1
		m1:Play()
		--wait(m1.TimeLength) --disabled because it makes looping part stuck playing if stopped too soon.
		if m1.TimePosition < m1.TimeLength then
			m2.Looped = true
			m2.Volume = 1
			m2:Play()
		else
			m1.Volume = 0
			m1:Stop()
		end
	elseif data["Horn"] == false then
		m1.Volume = 0
		m1:Stop()
		--For 3 part option
		m2.Volume = 0
		m2:Stop()
		m2.Looped = false
		m2.Playing = false
		m3.Volume = 1
		m3:Play()

		--[[ -- For 2 part option
		if m2.IsPlaying == true then
			for i=1, 0, -.1 do
				m2.Volume = i*1
				wait(.1)
			end
		end
		m2.Volume = 0
		m2.Looped = false
		m2.Playing = false
		m2:Stop()
		--]]
	end
end)
