Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Play Different Music in Different Areas?

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.

1 comment

0

:o u watch AB ?

1 answer

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

1 comment

0

I might have made a mistake somewhere in this code, but hopefully this helps you

This discussion is preserved as it was. New answers, comments, and votes are closed.