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 2 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 — 2y
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 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 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.

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.

0
fixed it QuestionableScript3r -6 — 2y
Ad

Answer this question