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

Text value in Properties tab is changing, but the real text on the screen isn't?

Asked by 4 years ago
Edited 4 years ago

I also have a video of it, but I dont know how to show it, so it would also be helpful if you could tell me that.

The title may sound a bit weird, but here is what it means: My script is basically a timer script. It changes the text of a TextLabel to act like a timer. but there is a weird problem... The Text "Value" in the Properties tab IS counting down and working perfectly, yet the actual TextLabel on the screen is not changing. It's staying at 5:00 (5 min : 0 sec) while in the properties tab, it's maybe at 4:36 seconds. Here is my code:

local ServerStorage = game:GetService("ServerStorage");
local StateOfGame = ServerStorage.StateOfGame;
local Timer = game.StarterGui.Players.Main.Timer;

local MidGame = false;

repeat wait() until StateOfGame;

function TimerCount()
    repeat wait() until game.StarterGui.Players.Main.Timer;
    if Timer.Sec.Value == 0 then
        Timer.Text = Timer.Min.Value..":00";
        wait(1)
        Timer.Min.Value -= 1;
        Timer.Sec.Value = 59;
    else
        Timer.Text = Timer.Min.Value..":"..Timer.Sec.Value;
        wait(1)
        Timer.Sec.Value -= 1;
    end
end

function GameEnd()
    if Timer.Min.Value == 0 and Timer.Sec.Value == 0 then
        return true;
    else
        return false;
    end
end

if StateOfGame.Value == "Start" and MidGame == false then
    MidGame = false;
    Timer.Min.Value = 5;
    Timer.Sec.Value = 0;
    while GameEnd() == false do
        TimerCount();
    end
end

It is a normal script inside of ServerScriptService.

1 answer

Log in to vote
1
Answered by
uhi_o 417 Moderation Voter
4 years ago

So the StarterGui replicates to the player's PlayerGui when the user joins the game. For that reason you must get all the players PlayerGui and change the text there. Or you can fire a remote on the client which would change it. So basically everything in StarterGui clones in the player that joined PlayerGui and StarterGui being the default guis for your game in some way.

Here is small sample that you can use to change all the players text.

for _, v in ipairs(game.Players:GetPlayers()) do
    local Timer = v.PlayerGui.Players.Main.Timer
    --bla bla...
end

Useful links: https://scriptinghelpers.org/questions/29534/can-someone-explain-to-me-the-difference-between-starter-gui-and-player-gui https://developer.roblox.com/en-us/api-reference/class/PlayerGui

Hope this has helped you.

Ad

Answer this question