I made a round system that teleports players and even has it own gui
The problem is I made a gui ready button and an integer value
When a player presses the button the integer value goes up by 1
I made an if statement to check if the integer value is 5 then it will run the round system script
but it doesn’t work at all I even tested it with 5 players all clicked the gui button but it still
doesn’t work please help
The integer value is called PlayersReady
Here is my code
local intermition = 30
local roundLength = 60
local inRound = game.ReplicatedStorage.InRound
local status = game.ReplicatedStorage.Status
local PlayersReady = game.ReplicatedStorage:WaitForChild("PlayersReady")
local TextButton = game:GetService("StarterGui").ReadyGui.Ready
if PlayersReady.Value == 5 then
TextButton.Visible = false
inRound.Changed:Connect(function()
if inRound.Value == true then
for i, player in pairs(game.Players:GetPlayers()) do
local char = player.Character
char:PivotTo(game.Workspace.GreenPart.CFrame)
end
else
for i, player in pairs(game.Players:GetPlayers()) do
local char = player.Character
char:PivotTo(game.Workspace.SpawnLocation.CFrame)
TextButton.Visible = true
PlayersReady.Value = 0
end
end
end)
local function round()
while true do
inRound.Value = false
for i = intermition, 0, -1 do
status.Value = "Game will start in "..i.." seconds"
wait(1)
end
inRound.Value = true
for i = roundLength, 0, -1 do
status.Value = "Game will end in "..i.." seconds"
wait(1)
end
end
end
spawn(round)
end
local TextButton = game:GetService("StarterGui").ReadyGui.Ready
it’s starter gui button and when you change starter gui that doen’t change every plr’s gui in server.
You should to change it for all players.
it changes gui only for those who died and respawned if your screen gui has ResetOnRespawn.
Try this.
for i,plr in ipairs(game:GetService("Players"):GetChildren()) do
local plrgui = plr.PlayerGui
local readygui = plrgui:WaitForChild("ReadyGui",10)
local button = readygui.Ready
button.Visible = false
end
I don’t understand?
What button?
I just putted it like this:
if PlayersReady.Value == 5 then
TextButton.Visible = false
for i,plr in ipairs(game:GetService("Players"):GetChildren()) do
local plrgui = plr.PlayerGui
local readygui = plrgui:WaitForChild("ReadyGui",10)
local button = readygui.Ready
button.Visible = false
end
inRound.Changed:Connect(function()
if inRound.Value == true then
for i, player in pairs(game.Players:GetPlayers()) do
local char = player.Character
char:PivotTo(game.Workspace.GreenPart.CFrame)
end
else
for i, player in pairs(game.Players:GetPlayers()) do
Nope didn’t work i think its actually a problem with the gui I think guis don’t work in server script so i need to make a remote event to fire from server to client
And then make the gui from the client
No, better just add the local script in button.
with this
local button = script.Parent
button.MouseButton1Click:Connect(function()
button.Visible = false
end)
or
local button = script.Parent
button.MouseButton1Click:Connect(function()
if game.ReplicatedStorage:WaitForChild("PlayersReady").Value == 5 then
button.Visible = false
end
end)