In my code (game.StarterGui.ScreenGui.Frame.LocalScript)
local Transitionnow = false
local shopentrance1 = game.Workspace.Shopintrobutton
local Frame = script.Parent
local Message = Frame:WaitForChild("TextBox")
local musicisplaying = false
local music = game.Workspace.SHOPMusics.Purpleland
function transition()
if not Transitionnow and not musicisplaying then
Transitionnow = true
Frame:TweenPosition(UDim2.new(0,0,0,0))
Message.Text = "Entering Shop zone"
wait(1.5)
Frame:TweenPosition(UDim2.new(0,0,-0.4,0))
music:Play()
musicisplaying = true
Transitionnow = false
end
if not Transitionnow and musicisplaying then
Transitionnow = true
Frame:TweenPosition(UDim2.new(0,0,0,0))
Message.Text = "Leaving Shop zone"
wait(1.5)
Frame:TweenPosition(UDim2.new(0,0,-0.4,0))
music:Stop()
musicisplaying = false
Transitionnow = false
end
end
shopentrance1.Touched:connect(transition)
I'm trying to imitate the effect (in Pokemon), where when your character moves to a different area, a sign/gui appears at the top with the name of the area you have just arrived to (ex: in Pokemon FireRed: Route 1, Pallet Town, etc).
The problem I am having is that the gui does tween in and out, and that the music does play, but the music ends immediately after the next if statement. I have no idea how to make it such that:
Player steps on brick
Brick causes function to run .... which shows the gui tweening in and out
Music plays (while Player does not step on brick)
Player steps on brick AGAIN
Brick -> Function runs -> Gui tweens in and out
Music stops
Thank you for your help!

2 comments
You might be able to implement wait(music.TimeLength); to make sure the music has finished playing, then call music:Stop();
Put them after each other in the script. It will do the first one first. Also, maybe put it a wait()