My problem with my waiting gui script

The left frame has the Ready and Controls buttons.
The right frame is It is used to show the player when the player presses the ready button.

And then the problem is What should I do if all the players tick all the boxes and the game starts immediately? (P.S. I make a ghost game but I don’t know how to do it.)

– Video of my map

If you don’t understand what I’m trying to convey, I have an example of that game. which I use as inspiration

It is from 00:00 to 00:20 seconds.

I may reply a little late. I apologize here too.

so if I’m understanding correctly, you wish to skip the wait timer if you press ready?

1 Like

Yes, but what do you do when everyone presses the ready button and the game starts immediately? I have 2 rough pictures below in case it’s easier to understand.

Picture1

Picture2

Picture3

Just to understand, you want to wait until all players are “ready” and not start imidiately when player clicks ready?

1 Like

Yes, that’s exactly what I’m going to convey.

Alrighty! Do you handle the timer in a server script and use the ready buttons to send remote events currently or how have you implemented your current version?

1 Like

My timer is in the client inside the TextLabel. I have a script that I made earlier. Can I send you the code line?

Of course, you can send what you have made so far and we can figure it out :smiley: Make sure to wrap the code with backticks so it’ll be easier to read!
```
print(“Hello World”)
```
Turns to:

print("Hello World")
1 Like

TimerHandler inside TextLabel

local plrs = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local runs = game:GetService("RunService")
local plr = plrs.LocalPlayer
local SentPlayerStatus = rep:WaitForChild("SentPlayerStatus", 5)
local GameRunningEvent = rep:WaitForChild("GameRunningEvent", 5)
local playerStatus = plr:WaitForChild("PlayerStatus", 5)
local isReady = playerStatus:WaitForChild("IsReady", 5)

local TimerText = script.Parent
local isReady = false
local ServerData = workspace:WaitForChild("ServerData", 5)
local LobbyRunning = ServerData:WaitForChild("LobbyRunning", 5)
local GameRunning = ServerData:WaitForChild("GameRunning", 5)

for i = 70, 0, -1 do
	TimerText.Text = i
	
	if i <= 0 then
		GameRunningEvent:FireServer(true)
		LobbyRunning.Value = false
		GameRunning.Value = true
	end
	
	task.wait(1)
end

and player frame when player added

local plrs = game:GetService("Players")

local frame = script.Parent
local container = frame:WaitForChild("Container", 5)
local template = script:WaitForChild("Template", 5)

local camera = workspace.CurrentCamera
local cameraPart = workspace:WaitForChild("CameraTest", 5)

function updatePlayers()
	for i, child in pairs(container:GetChildren()) do
		if child:IsA("Frame") then
			child:Destroy()
		end
	end
	
	for i, plr in pairs(plrs:GetPlayers()) do
		local playerImage = plrs:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
		
		local templateClone = template:Clone()
		templateClone.PlayerName.Text = plr.DisplayName
		templateClone.PlayerImage.Image = playerImage
		templateClone.Parent = container
		
		local playerStatus = plr:WaitForChild("PlayerStatus", 5)
		local isReady = playerStatus:WaitForChild("IsReady", 5)
		
		if isReady.Value == true then
			templateClone.CheckmarkImage.Image = "rbxassetid://16954666707"
			templateClone.CheckmarkImage.ImageColor3 = Color3.fromRGB(255,255,0)
		else
			templateClone.CheckmarkImage.Image = "rbxassetid://12376829585"
			templateClone.CheckmarkImage.ImageColor3 = Color3.fromRGB(255,0,0)
		end
		isReady:GetPropertyChangedSignal("Value"):Connect(function()
			if isReady.Value == true then
				templateClone.CheckmarkImage.Image = "rbxassetid://16954666707"
				templateClone.CheckmarkImage.ImageColor3 = Color3.fromRGB(255,255,0)
			else
				templateClone.CheckmarkImage.Image = "rbxassetid://12376829585"
				templateClone.CheckmarkImage.ImageColor3 = Color3.fromRGB(255,0,0)
			end
		end)
	end
end

updatePlayers()
plrs.PlayerAdded:Connect(updatePlayers)
plrs.PlayerRemoving:Connect(updatePlayers)

and server side to sent BoolValue to IsReady

local rep = game:GetService("ReplicatedStorage")
local SentPlayerStatus = rep:WaitForChild("SentPlayerStatus", 5)

SentPlayerStatus.OnServerEvent:Connect(function(plr, bool, name)
	local playerStatus = plr:WaitForChild("PlayerStatus", 5)
	local isReady = playerStatus:WaitForChild("IsReady", 5)
	
	isReady.Value = bool
	for i, v in pairs(rep.PlayerIsReady:GetChildren()) do
		if v:IsA("BoolValue") and v.Name == name then
			v.Value = bool
		end
	end
end)

Ok awesome! What I’m seeing here is that you have a way to start the game with this:

So when a player toggles themselves ready, you should check if everyone is ready and then activate the GameRunning. Something like this:

SentPlayerStatus.OnServerEvent:Connect(function(plr, bool, name)
	local playerStatus = plr:WaitForChild("PlayerStatus", 5)
	local isReady = playerStatus:WaitForChild("IsReady", 5)
	
	isReady.Value = bool
	local AllReady = bool
	for i, v in pairs(rep.PlayerIsReady:GetChildren()) do
		if v:IsA("BoolValue") and v.Name == name then
			v.Value = bool
			AllReady = AllReady and v.Value
		end
	end
	if AllReady then
		-- Start the game!
	end
end)

I also recommend handling the timer on the server because now if I join my timer starts ticking but if you join 10 seconds later then my timer and your timer will not be the same :smiley:

Hopefully this helps you forward! Let me know if you got more questions! :smiley:

EDIT: Had a typo

2 Likes

I’m going to take the test. If it doesn’t work, I’ll reply and tell you what’s wrong. I’ll come back soon. :grinning:

1 Like

I went to test it with my friend, but
It seems that if we “Ready” it will be ticked. But the other person isn’t “Ready” yet, he crosses the line, the game starts right away.

Did I write something wrong?

Are you able to send your updated scripts here so we can take a look?

1 Like

Previously, I forgot to bring the script, so I’ll put the “Ready” button here as well.

Here Button Ready Handler

local plrs = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local plr = plrs.LocalPlayer
local SentPlayerStatus = rep:WaitForChild("SentPlayerStatus", 5)
local playerStatus = plr:WaitForChild("PlayerStatus", 5)
local isReady = playerStatus:WaitForChild("IsReady", 5)

local Button = script.Parent
Button.MouseButton1Click:Connect(function()
	if not isReady.Value then
		SentPlayerStatus:FireServer(true, plr.DisplayName)
	else
		SentPlayerStatus:FireServer(false, plr.DisplayName)
	end
end)

and a update timer in local script

local plrs = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local runs = game:GetService("RunService")
local plr = plrs.LocalPlayer
local SentPlayerStatus = rep:WaitForChild("SentPlayerStatus", 5)
local GameRunningEvent = rep:WaitForChild("GameRunningEvent", 5)
local playerStatus = plr:WaitForChild("PlayerStatus", 5)
local isReady = playerStatus:WaitForChild("IsReady", 5)

local TimerText = script.Parent
local isReady = false
local ServerData = workspace:WaitForChild("ServerData", 5)
local LobbyRunning = ServerData:WaitForChild("LobbyRunning", 5)
local GameRunning = ServerData:WaitForChild("GameRunning", 5)

local ServerData = workspace:WaitForChild("ServerData", 5)
local TimerValue = ServerData:WaitForChild("Timer", 5)

function updateTimer()
	TimerText.Text = TimerValue.Value
	
	if TimerValue.Value <= 0 then
		GameRunningEvent:FireServer(true)
		LobbyRunning.Value = false
		GameRunning.Value = true
	end
end

updateTimer()
TimerValue:GetPropertyChangedSignal("Value"):Connect(updateTimer)

and timer server

local ServerData = workspace.ServerData
local TimerValue = ServerData.Timer

local intermission = 300
for i = intermission, 0, -1 do
	TimerValue.Value = i
	task.wait(1)
end

and the last one server side to sent BoolValue to IsReady

local rep = game:GetService("ReplicatedStorage")
local SentPlayerStatus = rep:WaitForChild("SentPlayerStatus", 5)

SentPlayerStatus.OnServerEvent:Connect(function(plr, bool, name)
	local playerStatus = plr:WaitForChild("PlayerStatus", 5)
	local isReady = playerStatus:WaitForChild("IsReady", 5)
	
	isReady.Value = bool
	local AllReady = bool
	for i, v in pairs(rep.PlayerIsReady:GetChildren()) do
		if v:IsA("BoolValue") and v.Name == name then
			v.Value = bool
			AllReady = AllReady and v.Value
		end
	end
	if AllReady then
		print("Start")
	end
end)

Sorry for the long code line. Because I didn’t manage the line of codes as well enough. I apologize here.

Sorry for the slow response! I think you are very close to being done.

First lets remove the time runs out logic from the localscript and only leave what we need:

local ServerData = workspace:WaitForChild("ServerData", 5)
local TimerValue = ServerData:WaitForChild("Timer", 5)

local TimerText = script.Parent

function updateTimer()
	TimerText.Text = TimerValue.Value
end

updateTimer()
TimerValue:GetPropertyChangedSignal("Value"):Connect(updateTimer)

And then lets combine Timer server and script that sets boolvalue to IsReady:


local ServerData = workspace.ServerData
local TimerValue = ServerData.Timer

local rep = game:GetService("ReplicatedStorage")
local SentPlayerStatus = rep:WaitForChild("SentPlayerStatus", 5)
local ServerData = workspace:WaitForChild("ServerData", 5)
local LobbyRunning = ServerData:WaitForChild("LobbyRunning", 5)
local GameRunning = ServerData:WaitForChild("GameRunning", 5)

local ForceStart = false

SentPlayerStatus.OnServerEvent:Connect(function(plr, bool, name)
	local playerStatus = plr:WaitForChild("PlayerStatus", 5)
	local isReady = playerStatus:WaitForChild("IsReady", 5)
	
	isReady.Value = bool
	local AllReady = bool
	for i, v in pairs(rep.PlayerIsReady:GetChildren()) do
		if v:IsA("BoolValue") and v.Name == name then
			v.Value = bool
			AllReady = AllReady and v.Value
		end
	end
	if AllReady then
		-- Everyone is ready! Activate the game!
		ForceStart = true
	end
end)

local intermission = 300
for i = intermission, 0, -1 do
	if ForceStart then
		-- Everyone is ready! End the timer early!
		TimerValue.Value = 0
		break
	end
	TimerValue.Value = i
	task.wait(1)
end
LobbyRunning.Value = false
GameRunning.Value = true

-- Start the game for everyone!

Hopefully that works out for you! :smiley:

1 Like

Sorry for the late reply. It’s the same again. I wrote exactly as you did but it’s still the same.
There is a video attached. But it might be a little jerky, but that’s okay.

And update all script

update timer in local script

local TimerText = script.Parent

local ServerData = workspace:WaitForChild("ServerData", 5)
local TimerValue = ServerData:WaitForChild("Timer", 5)

function updateTimer()
	TimerText.Text = TimerValue.Value
end

updateTimer()
TimerValue:GetPropertyChangedSignal("Value"):Connect(updateTimer)

and the last one server side to sent BoolValue to IsReady

local rep = game:GetService("ReplicatedStorage")
local SentPlayerStatus = rep:WaitForChild("SentPlayerStatus", 5)

-- Valueables
local ServerData = workspace:WaitForChild("ServerData", 5)
local LobbyRunning = ServerData:WaitForChild("LobbyRunning", 5)
local GameRunning = ServerData:WaitForChild("GameRunning", 5)

-- Timers Asset
local ServerData = workspace.ServerData
local TimerValue = ServerData.Timer

-- Modules
local modules = rep:WaitForChild("Modules", 5)
local DialogueModule = require(modules:WaitForChild("Dialogue"))
local Objective = require(modules:WaitForChild("Objective"))

local ForceStart = false
local isTalking = false

function dialogue1()
	task.wait(1)
	if not isTalking then
		isTalking = true
		DialogueModule.AllPlayerDialogue("Where are we?.", 3)
		task.wait(3)
		isTalking = false
	end
	task.wait(3)
	if not isTalking then
		isTalking = true
		DialogueModule.AllPlayerDialogue("Where is this place and we are unconscious?", 3)
		task.wait(3)
		isTalking = false
	end
	task.wait(3)
	if not isTalking then
		isTalking = true
		DialogueModule.AllPlayerDialogue("Why is this place so bad? Must get out of here", 3)
		task.wait(3)
		isTalking = false
	end
	task.wait(1)
	Objective.CreateObjective("Find flashlight", "Objective_Normal", workspace.Items.Flashlight.Name)
	Objective.CreateObjective("Find candle", "Objective_Pick", "Candle", 5)
	task.wait(3)
	Objective.CreateObjective("Place candle", "Objective_Place", "Candle", 5)
end

SentPlayerStatus.OnServerEvent:Connect(function(plr, bool, name)
	local playerStatus = plr:WaitForChild("PlayerStatus", 5)
	local isReady = playerStatus:WaitForChild("IsReady", 5)
	
	isReady.Value = bool
	local AllReady = bool
	for i, v in pairs(rep.PlayerIsReady:GetChildren()) do
		if v:IsA("BoolValue") and v.Name == name then
			v.Value = bool
			AllReady = AllReady and v.Value
		end
	end
	if AllReady then
		-- Everyone is ready! Activate the game!
		print("Everyone is ready! Activate the game!")
		ForceStart = true
	end
end)

local intermission = 300
for i = intermission, 0, -1 do
	if ForceStart then
		-- Everyone is ready! End the timer early!
		TimerValue.Value = 0
		break
	end
	TimerValue.Value = i
	task.wait(1)
end
LobbyRunning.Value = false
GameRunning.Value = true
print("Start the game for everyone!")
dialogue1()

I added a dialoge and objective system below timer ran out the time

Ok I figured out what the issue is, can you send me the localscript where you run SentPlayerStatus:FireServer? I’ll edit the code once I get on studio :smiley:

1 Like

okay, no problem
Here the SentPlayerStatus come from

local plrs = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local plr = plrs.LocalPlayer
local SentPlayerStatus = rep:WaitForChild("SentPlayerStatus", 5)
local playerStatus = plr:WaitForChild("PlayerStatus", 5)
local isReady = playerStatus:WaitForChild("IsReady", 5)

local Button = script.Parent
Button.MouseButton1Click:Connect(function()
	if not isReady.Value then
		SentPlayerStatus:FireServer(true, plr.DisplayName)
	else
		SentPlayerStatus:FireServer(false, plr.DisplayName)
	end
end)

It is inside my “Ready” button