To do this is simple you just need to set up a few things
First put a LocalScript in the StarterGui
Next place a Sound object inside of the LocalScript and set up the SoundId
Then name the sound "OnSpawn" (Important!)
Lastly put one of the two codes (see below) in the LocalScript
If you want to play the music only the first time a player joins a server use this code :
1 | player = game:GetService( "Players" ).LocalPlayer |
2 | sound = script.Parent:FindFirstChild( "OnSpawn" ) |
3 | content = game:GetService( "ContentProvider" ) |
4 | content:Preload(sound.SoundId) |
6 | if player:FindFirstChild( "FirstTime" ) = = nil then |
7 | Instance.new( "Flag" ,player).Name = "FirstTime" |
If you want to play the music every time the player spawns use this code :
1 | player = game:GetService( "Players" ).LocalPlayer |
2 | sound = script.Parent:FindFirstChild( "OnSpawn" ) |
3 | content = game:GetService( "ContentProvider" ) |
4 | content:Preload(sound.SoundId) |
If you have any questions, concerns or just need some help with this PM me on ROBLOX!