So I bassically made two scripts, one that my goal was to make the background music of the game (SONIC) play when you leave an area were (HALO) is playing. Bassically, I put a brick that changes the music once you go into a house into HALO, and then I made a brick that changes the music back to SONIC when you step out of the house. Here's both scripts.
function onTouch(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if game.Workspace.TV.Script.HALO.IsPlaying == true then
game.Workspace.TV.Script.HALO:Stop()
wait(1)
game.Workspace.SONIC:Play()
end
end
end
game.Workspace.MusicPlay.Touched:connect(onTouch)
function onTouch(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if game.Workspace.SONIC.IsPlaying == true then
game.Workspace.SONIC:Stop()
wait(1)
game.Workspace.TV.Script.HALO:Play()
end
end
end
game.Workspace.MusicPlay.Touched:connect(onTouch)
My problem is when I repededly walk over the blocks, the songs get messed up and start to randomly change eachother. I just want a song to play in a certain area, and then stop playing once out of that area. How would I be able to do that?
