Round System Ending Too Fast

  1. What do you want to achieve? Keep it simple and clear!
    my round script is going too fast
  2. What is the issue? Include screenshots / videos if possible!
    i’ll make a video soon
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i tried changing the wait but it doesn’t seem to do anything

-Server Script

local Remotes = game.ReplicatedStorage.Remotes
local ToggleStart = Remotes.ToggleStart
local CheckIfGameStarted = Remotes.CheckIfGameStarted
local CheckPainter = Remotes.CheckPainter
local PlaceBlock = Remotes.PlaceBlock
local GetPrompt = Remotes.GetPrompt
local Players = game.Players
local Prompts = require(game.ServerScriptService.Prompts)
local ROUND_TIME = 60

function StartGame()
	local GameStarted = game.ServerStorage.GameStarted
	local Painter = game.ServerStorage.Painter
	local GameRestart
	GameStarted.Value = not GameStarted.Value
	if GameStarted.Value == true then
		print("game has indeed started")
		Painter.Value = Players:GetPlayers()[math.random(1,#Players:GetPlayers())].Name
		local PainterPlr = game.Players:FindFirstChild(Painter.Value)
		local PainterCharacter = PainterPlr.Character or PainterPlr.CharacterAdded:Wait()
		repeat wait() until PainterCharacter
		PainterCharacter.HumanoidRootPart.Position = game.Workspace.GameArea.Canvas.Position
		for i,v in pairs(game.Workspace.GameArea.PaintParts:GetChildren()) do
			v:Destroy();
		end
		game.ServerStorage.Prompt.Value = Prompts[math.random(1,#Prompts)]
		
		GameRestart = coroutine.create(function()
			task.wait(ROUND_TIME)
			StartGame()
			task.wait(1)
			StartGame()
		end)



		coroutine.resume(GameRestart)


		Players.PlayerRemoving:Connect(function(plr)
			if plr.Name == game.ServerStorage.Painter.Value then
				coroutine.close(GameRestart)
				StartGame()
				task.wait(ROUND_TIME)
				StartGame()
			end
		end)
		
		PainterCharacter.Humanoid.Died:Connect(function()
			coroutine.close(GameRestart)
			StartGame()
			task.wait(ROUND_TIME)
			StartGame()
		end)

	else
		local PainterPlr = game.Players:FindFirstChild(Painter.Value)
		local PainterCharacter = PainterPlr.Character or PainterPlr.CharacterAdded:Wait()

		PainterCharacter.HumanoidRootPart.Position = game.Workspace.SpawnLocation.Position
		for i,v in pairs(game.Workspace.GameArea.PaintParts:GetChildren()) do
			v:Destroy();
		end
	end
end

ToggleStart.OnServerEvent:Connect(function()
	StartGame()
end)

CheckIfGameStarted.OnServerInvoke = function() 
	return game.ServerStorage.GameStarted.Value
end

CheckPainter.OnServerInvoke = function(plr,painterToCheck)
	if game.ServerStorage.Painter.Value == painterToCheck then
		return true
	else
		return false
	end
end

PlaceBlock.OnServerEvent:Connect(function(plr,color,cframe)
	if plr.Name == game.ServerStorage.Painter.Value then
		local BlockTemplate = game.ReplicatedStorage.Assets.BlockTemplate:Clone()
		BlockTemplate.Color = color
		BlockTemplate.CFrame = cframe
		BlockTemplate.Parent = game.Workspace.GameArea.PaintParts
		BlockTemplate.Anchored = true
	end

end)

GetPrompt.OnServerInvoke = function(plr)
	return game.ServerStorage.Prompt.Value
end



game.Players.PlayerAdded:Connect(function(plr)
	if #game.Players:GetPlayers() > 1 then
		task.wait(1)
		StartGame()
		task.wait(ROUND_TIME)
		ToggleStart:FireClient(plr)
	end
	plr.Chatted:Connect(function(msg)
		if msg == game.ServerStorage.Prompt.Value and plr.Name ~= game.ServerStorage.Painter.Value then
			
			StartGame()
			for i,v in pairs(game.Players:GetPlayers()) do
				local UI = v.PlayerGui
				local MainGui = UI.MainGui
				MainGui.CommentaryLabel.Text = plr.Name.." got the correct answer of: "..game.ServerStorage.Prompt.Value
				task.wait(0.5)
				MainGui.CommentaryLabel.Text = "Someone is drawing."
			end
			task.wait(1)
			StartGame()
		end
		
	end)
end)

–Client Script

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Players = game:GetService("Players")
local PlayerUI = Player:WaitForChild("PlayerGui")
local MainGui = PlayerUI:WaitForChild("MainGui")
local Remotes = game.ReplicatedStorage.Remotes
local RunService = game:GetService("RunService")
local CheckIfGameStarted = Remotes.CheckIfGameStarted
local CheckPainter = Remotes.CheckPainter
local PlaceBlock = Remotes.PlaceBlock
local ToggleStart = Remotes.ToggleStart
local GetPrompt = Remotes.GetPrompt
local mouse = Player:GetMouse()
local UIS = game:GetService("UserInputService")
local isPainter = false
local currentColor = Color3.new(0,0,0)

if CheckIfGameStarted:InvokeServer() then
	MainGui.CommentaryLabel.Text = "Someone is painting"
end


ToggleStart.OnClientEvent:Connect(function()
	if CheckIfGameStarted:InvokeServer() then
		MainGui.CommentaryLabel.Text = "Someone is painting"
	else
		MainGui.CommentaryLabel.Text = "At least 2 players needed to start"
	end
end)



mouse.Button1Down:Connect(function()
	mouse.TargetFilter = game.Workspace.GameArea.Walls
	if isPainter then
		if mouse.Target.Parent == game.Workspace.GameArea.Colors then
			currentColor = mouse.Target.Color
			MainGui:WaitForChild("ColorFrame").BackgroundColor3 = currentColor

		end

	end
end)

task.spawn(function()
	while true do
		if UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) then

			if mouse.Target and isPainter then
				if mouse.Target.Name == "Canvas" and mouse.Target.Parent == game.Workspace.GameArea then
					PlaceBlock:FireServer(currentColor,mouse.Hit)
				end
			end


		end
		task.wait()
	end


end)


task.spawn(function()
	while true do
		isPainter = CheckPainter:InvokeServer(Player.Name)
		if isPainter then
			if MainGui:WaitForChild("ColorFrame").Visible == false then
				MainGui:WaitForChild("ColorFrame").Visible = true
			end
			if MainGui:WaitForChild("PromptLabel").Visible == false then
				MainGui:WaitForChild("PromptLabel").Visible = true
			end
			if MainGui:WaitForChild("PromptLabel").Text ~= "Prompt: "..GetPrompt:InvokeServer() then
				MainGui:WaitForChild("PromptLabel").Text = "Prompt: "..GetPrompt:InvokeServer()
			end
		else
			MainGui:WaitForChild("ColorFrame").Visible = false
			MainGui:WaitForChild("PromptLabel").Visible = false
		end
		
		task.wait(1)
	end
end)