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?
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.
01 | local plrs = 0 |
02 | local sound = workspace.brickwithsound.sound |
03 | local event = game.ReplicatedStorage.remoteevent |
04 | local gameover = game.ReplicatedStorage.gameover |
05 |
06 | local function OnPlrJoin(plr) |
07 | print (plr .. " joined." ) |
08 | if plrs = = 0 then |
09 | sound:Play() |
10 | end |
11 | plrs = plrs + 1 |
12 | end |
13 |
14 | local function GameOver() |
15 | plrs = 0 |
16 | end |
17 |
18 | gameover.OnServerEvent:Connect(GameOver) |
19 | event.OnServerEvent:Connect(OnPlrJoin) |
Sorry if this was bad.