My problem with my waiting gui script

Sorry for the wait! I believe this fixes our problem:

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") then
			if v.Name == name then
				v.Value = bool
			end
			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()

Though I do recommend not using plr.DisplayName for storing values because multiple players can have the same name. Its much safer to use plr.UserId because they are unique! Let me know if this fixes the issue :smiley:

It doesn’t seem to work at all when I press the “Ready” button. “PlayerIsReady” is a folder and inside it is something called a BoolValue. The name of this is the UserId of that player. And when I try to press the “Ready” button, the value on it doesn’t tick. I don’t know why.

I put print to check AllReady. it say false. So the game doesn’t start.

Are you able to show me a picture on what the folder looks like?

Folder
image

and properties

Ok! that explains because for some reason you were using DisplayName to check for it I think. I’ll again do few modifications and lets see if it works :smiley:

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)
	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") then
			if v.Name == tostring(plr.UserId) then
				v.Value = bool
			end
			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()
1 Like

Ok it work friend. thank you for helping me

Glad it finally worked :smiley: Good luck on your game!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.