Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make an audio/sound play on team spawn?

When a team spawns, I want it to play a sound as a server-side, but this sound will only be played once. I tried to get help on the internet or from a few people, but none of them went the way I wanted. So how exactly should I write a working script for this?

2 comments

0

Do all the team members spawn at the same time? If so I prob have the answer to this question

0

No, not at the same time, but that sound should play as soon as the first member spawns, and then not play again when a team member spawns again. In short, you can think of it as an announcement system.

1 answer

Insert the sound you want to play into a brickYou should keep a count. When the first player joins and a signal is sent to the server.

local plrs = 0
local sound = workspace.brickwithsound.sound
local event = game.ReplicatedStorage.remoteevent
local gameover = game.ReplicatedStorage.gameover

local function OnPlrJoin(plr)
	print(plr .. " joined.")
	if plrs == 0 then
		sound:Play()
	end
	plrs = plrs + 1
end

local function GameOver()
	plrs = 0
end

gameover.OnServerEvent:Connect(GameOver)
event.OnServerEvent:Connect(OnPlrJoin)

Sorry if this was bad.

1 comment

0

fixed it

This discussion is preserved as it was. New answers, comments, and votes are closed.