IntermissionSound delay

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    My audio delays while player resets or round starts
  2. 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

1 Like

You can use a BindableEvent to synchronize the start and end of each round

2 Likes

Could you help with it please?

1 Like

Do you have a separate script for teleporting the player?

1 Like

I have RoundSystem script and intermission GUI, I can add you in teamcrate and you can check

1 Like

Add a BindableEvent under round system script

Here an example for your major round script

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)

I am sorry I didn’t recognize that the script for playing sound itself dosen’t loaded so i have a bool value for make sure everything is okay

an example script for major round system


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)
1 Like