Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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?

0
Do all the team members spawn at the same time? If so I prob have the answer to this question Jay123abc2 241 — 3y
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. AyaneeRedD 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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.

01local plrs = 0
02local sound = workspace.brickwithsound.sound
03local event = game.ReplicatedStorage.remoteevent
04local gameover = game.ReplicatedStorage.gameover
05 
06local function OnPlrJoin(plr)
07    print(plr .. " joined.")
08    if plrs == 0 then
09        sound:Play()
10    end
11    plrs = plrs + 1
12end
13 
14local function GameOver()
15    plrs = 0
16end
17 
18gameover.OnServerEvent:Connect(GameOver)
19event.OnServerEvent:Connect(OnPlrJoin)

Sorry if this was bad.

0
fixed it QuestionableScript3r -6 — 3y
Ad

Answer this question