Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

SurfaceGui not updating for all players?

Asked by 3 years ago

I'm trying to make a ready system, so when a player presses a button on a surfaceGui it updates the surfaceGui for everyone and says that the player is ready. I have more to this script but it has nothing to do with the question so i'm only going to put the ready system in the code down below.

Server script in ServerScriptService:

local Players = game:GetService("Players")

local rs = game.ReplicatedStorage

local PlrReadySt = "Not Ready"

local function onPlayerReady(player)
for i,readyPlr in pairs(game.Players:GetChildren()) do
    for i,v in pairs(readyPlr.PlayerGui.MainUi.SurfaceGui.MainFrame.InfoFrame.PlrList:GetChildren()) do
        if v.Name == player.Name then
            if PlrReadySt == "Ready" then
                PlrReadySt = "Not Ready"
                v.StReady.Text = PlrReadySt 
                player.Ready.Value = false
            else
                PlrReadySt = "Ready"
                v.StReady.Text = PlrReadySt 
                player.Ready.Value = true
            end
        end
    end
end
end
rs.Events.PlayerReady.OnServerEvent:Connect(onPlayerReady)

Local script in StarterGui:

local Players = game:GetService("Players")

local function onReadyBtn()
    game.ReplicatedStorage.Events.PlayerReady:FireServer()
end

script.Parent.MainUi.SurfaceGui.MainFrame.ReadyBtn.MouseButton1Click:Connect(onReadyBtn)

Answer this question