You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
My audio delays while player resets or round starts
What is the issue? Include screenshots / videos if possible!
Here is video
Here is my script
local sound = game.Workspace.IntermissionSound
local intermissionTime = 24.5
local roundTime = 12
function areAllPlayersDead()
for _, player in pairs(game.Players:GetPlayers()) do
if player.Character and player.Character:FindFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 then
return false
end
end
return true
end
while true do
sound:Play()
wait(intermissionTime)
sound:Stop()
local roundStartTime = tick()
while tick() - roundStartTime < roundTime do
if areAllPlayersDead() then
break
end
wait(5)
end
sound:Stop()
end
local music_event = script.Music_Event --- This is Round system example
local intermissionTime = 24.5
local roundTime = 12
local Sound = game.Workspace:WaitForChild("Sound") -- make sure the script is loaded
function areAllPlayersDead()
for _, player in pairs(game.Players:GetPlayers()) do
if player.Character and player.Character:FindFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 then
return false
end
end
return true
end
while true do
music_event:Fire(true)
wait(intermissionTime)
music_event:Fire(false)
local roundStartTime = tick()
while tick() - roundStartTime < roundTime do
if areAllPlayersDead() then
break
end
wait(5)
end
music_event:Fire(false)
end
This is a script for intermission sound
local sound = game.Workspace.IntermissionSound
local music_event = workspace.Main_round_System.Music_Event
music_event.Event:Connect(function(input)
if input == true then
sound:Play()
else
sound:Stop()
end
end)
local music_event = script.Music_Event
local intermissionTime = 24
local roundTime = 1
local ready = script.Ready
function areAllPlayersDead()
for _, player in pairs(game.Players:GetPlayers()) do
if player.Character and player.Character:FindFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 then
return false
end
end
return true
end
repeat
task.wait()
until script.Ready.Value == true
while true do
music_event:Fire(true)
wait(intermissionTime)
music_event:Fire(false)
local roundStartTime = tick()
while tick() - roundStartTime < roundTime do
if areAllPlayersDead() then
break
end
wait(5)
end
music_event:Fire(false)
end
this for playing music
local sound = game.Workspace.IntermissionSound
local music_event = workspace.Main_round_System.Music_Event
local ready = workspace.Main_round_System.Ready
ready.Value = true
music_event.Event:Connect(function(input)
if input == true then
sound:Play()
else
sound:Stop()
end
end)