Sound/Audio Playing When A Player Joins The Game

Hey Developers!

I’ve been stuck trying to figure out how to play a sound when a player joins the game. I’ve looked all over the devforum and couldn’t find anything useful. I’ve made my own code, but it’s not playing at all.

This is my code:

local sound = Instance.new("Sound", script.Parent) script
sound.SoundId = "rbxassetid://10787981997" 
game.Players.PlayerAdded:Connect(function(player)
	wait(3)
	sound:Play() 
end)

I’m confused why the sound won’t play, and it’s not giving me any errors in the output.

If you know any solution to this problem, please let me know!

1 Like

Is this in a local script?
What is the script parented in?

Sounds need to be in the workspace or inside a Part if I remember correctly.
Why not just manually put this Sound in the Workspace and get the script to play it instead of adding it and playing it locally?

Are you trying to do this locally or on server side?

This should be inside the ServerScriptService

local Part = --local the part

game.Players.PlayerAdded:Connect(function()
	local sound = Instance.new("Sound", Part)
    sound.SoundId = "rbxassetid://10787981997" 

    sound:Play
end)
1 Like

This is in a local script, I don’t want to annoy other players when someone else joins the game.

Yes, I’m trying to do this locally

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.