How do I play music during rounds?

I have seen music play for rounds of games. Like in @masterdaniel’s speed race, @Wsly’s deathrun and @Polyhex’s super bomb survival.

I have tried using soundservice for this thing but it didn’t do it, it made the music silent and not do anything. The SoundService didn’t transfer sounds to the workspace, the workspace is where the round map is. I tried using the script:

game.ReplicatedStorage.MapFolder.Map1 = game:GetService(“SoundService”)

local sounds =

game.SoundService.Sound1

game.SoundService.Sound2

game.SoundService.Sound3

when game.ReplicatedStorage.MapFolder.Map1.Parent.Workspace = true do

game.SoundService.Sound1.Playing = true

when game.ReplicatedStorage.MapFolder.Map1.Parent.Workspace = false then

game.SoundService.Sound1.Playing = false

when game.SoundService.SoundArea.game.Workspace.Lobby.SoundService.Sound1.Playing = false 

This is difficult when your making a certain game and you want music ti play when a map is inside the workspace and it is not playing the music that you want it to. This for instance is when the players inside the map have music there. The main lobby is where the music DOESN’T play and the people inside the round only hear it. I believe this game will go nowhere without the music playing whenever a player is in a map and they don’t hear the music. Its technically when the player is in the lobby they don’t see or hear the normal round music, only the players inside the round hear it. Please help because this is difficult and hardcore because this project will not be good because it doesn’t have that thing when it has to be there in order for the game to be good and have high ratings, I tried using sound regions but they break a lot.

1 Like

I got a stroke reading this code I’m sorry but I don’t get what you’re trying to do here

3 Likes

Try this:

local SoundService = game:GetService("SoundService")

local Sound1, Sound2, Sound3 = SoundService.Sound1, SoundService.Sound2, SoundService.Sound3

if game.Workspace:FindFirstChild("Map1") then

Sound1:Play()

else

Sound1:Stop()

end

I don’t understand what do you want to do in the last line, can you explain?

The last line is when the player in the lobby doesn’t hear the round music.

There is a lobby team or something like that?

No, there isn’t a lobby team. There is no TeamService in the game so it is impossible to do the teams because a player cannot spawn inside a game because they would be stuck and die continuously until he leaves and dislikes the game.

You can insert the TeamService clicking here

image

is this the actual code? or is this some sort of planning? If this is the actual code, the code won’t work at all as there are many problems with it. Idk but I have never seen when used in luau.

If you’re trying to insert the map into the SoundService, that’s wrong. To make a sound play, you just do sound:Play().

How do I do it for multiple things? Like map1 and map2 both have music but is there something that I can do to make the music play in one map? Also, where does the script go?

I am sorry, but i have no idea what you actually wanna do with this script.

Just have some sounds in the workspace and when a round starts set them to looped and playing

Example of how to set the music

game.Workspace.Sound.Playing = true
game.Workspace.Sound.Looped = true

Also, don’t use when, that doesn’t really exists.

I haven’t found any answers on YouTube, the developer hub or on the dev forums. This is really hard because I used @Voltiqs’s script, but it still plays in workspace, not when the map is in workspace. This is pretty irritating on how I cannot make the music play when a player is in the round and it is a gigantic struggle for me now, as this is starting to make me feel like giving up because the rounds without music ruins the purpose of the game.