I want to have music play for players inside the minigame, I do not want the music from the minigame playing inside the lobby. I have music and a folder that tracks what players are in a minigame. I have tried many times before and have failed a lot.
You can use a RemoteEvent and send the name of the song for a LocalScript to play.
Server:
local Player:Player =
local Sound:string =
local Event = game:GetService("ReplicatedStorage").Musics
Event:FireClient(Player, Sound)
LocalScript:
local Event = game:GetService("ReplicatedStorage").Musics
Event.OnClientEvent:Connect(function(Name:string)
local Sound = Event:FindFirstChild(Name)
if Sound then
game:GetService("SoundService"):PlayLocalSound(Sound)
end
end)
Create the event in ReplicatedStorage and call it Musics and place the music as children, if you change its location only the variable Event changes.
Other source: PlayLocalSound