Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

Play Different Music in Different Areas?

Asked by 4 years ago

I am making a game that has a lobby and a map. I want music in the lobby and the map that are both different. How would I do that? I saw AlvinBlox's tutorial but it's out of date.

0
:o u watch AB ? LUCATIVIOMAD 31 — 4y

1 answer

Log in to vote
0
Answered by
sheepposu 561 Moderation Voter
4 years ago

I think the best option is to create a localscript in the StarterGui or PlayerScripts. Check if they are in the lobby by checking their vector and comparing it to the lobby's vector. If they are in the lobby, play lobby music. If they aren't, play map music. Below is an example where the lobby is 6 parts each in a folder

local lobby = workspace.Lobby
repeat wait() until game.Players.LocalPlayer.Character

local function InLobby()
    local plrVector = game.PLayers.LocalPlayer.Character.HumanoidRootPart.Position
    if plrVector.Y > lobby.Ceiling.Position.Y or plrVector.Y < lobby.Floor.Position.Y or plrVector.X > lobby.WallLeft.Position.X or plrVector.X < lobby.WallRight.Position.X or plrVector.Z > lobby.WallFront.Position.Z or plrVector.Z < lobby.WallBack.Position.Z then
        return false
    end
    return true
end

while true do
    wait()
    --Play lobby music
    repeat
        wait()
    until not InLobby()
    --Stop lobby Music
    --Play map music
    repeat
        wait()
    until InLobby()
    --stop map music
end
0
I might have made a mistake somewhere in this code, but hopefully this helps you sheepposu 561 — 4y
Ad

Answer this question