PlayerAdded script not working

I’m trying to make it so when a player joins, the windows 95 startup sound effect plays.
This is a local script in StarterScriptService:

local Players = game:GetService("Players")

local function Startup()
	game.SoundService.StartupSound:Play()
end

local function onPlayerAdded(player)
	if player.PlayerAdded then
		Startup()
	end
end

You haven’t actually called the function

game.Players.PlayerAdded:Connect(function(player)
    game.SoundService.StartupSound:Play()
end)

Your code is not working because you aren’t running your functions, and your indexing .PlayerAdded incorrectly and not in the right instance. The code above should work.

3 Likes

No wait never mind I don’t think u have to call it on playeradded

What is “StarterScriptService”? If you put the local script inside of the ServerScriptService, it won’t run.

1 Like

Oh yeah blueberry good that’s what I was trynna say kinda :sweat_smile:

But I need it to be a local script, because I don’t want the startup sound to be playing every time someone joins the server.

Then just play the sound after a few seconds, you don’t need PlayerAdded for that.

1 Like

Wait I worded badly cause I only got 4 hours of sleep. I want it the sound to be only heard to the player who joined the server; sorry for the confusion.

Yes.

-- client:
task.wait(3) -- Or another loading method
game.SoundService.StartupSound:Play()

doesn’t work, and nothing shows in output. HELP

Where are you putting the LocalScript?

This is a client script, and this is in serverScriptService

A client script in SERVERScriptService? You should put it in StarterPlayerScripts or ReplicatedFirst.

1 Like

I would put a script in StarterPlayerScripts then play the sound at the beginning of the script. No need for players added event

Welp im mentally disabled. Ty so much.

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