Client Sided Music When Players Join the Game

I recently created a post asking how to make client sided sounds play when touching a part. (Client Sided Sounds) I want to do the same thing, but for when players join the game, but I am having trouble figuring out what to do.

  1. What do you want to achieve? I want to have music play for the LocalPlayer only when they join the game.

  2. What is the issue? I do not know how to do it.

  3. What solutions have you tried so far? I looked for similar posts, but couldn’t find anything. I also looked into the Developer Hub, but still didn’t find my answer.

This is the LocalScript put in Workspace:

game.Players.PlayerAdded:Connect(function()
    game.Workspace.Music:Play()
end)

With prior knowledge, I assume I’d have to use LocalPlayer, but as a beginner scripter, I do not know how to go by that. Any help is appreciated. :slightly_smiling_face:

Just use a local script inside starter character to setup the music. I believe that would work.

Any client sided sound you can play on the starter GUI which is only client related

LocalScripts do not function in the Workspace, but you’re on the right track of using that. Simply move this to StarterPlayerScripts, get rid of the PlayerAdded stuff, use WaitForChild on Music and then play it.

1 Like

Would the script (that is now in StarterPlayerScripts) go like this?

local music = game.Workspace:WaitForChild("Music")

music:Play()

Yep looks all good, PlayerScripts are added only once and therefore ran only once.
FYI: You can use the workspace keyword instead of having to write out game.Workspace

1 Like