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

How do I make the ScreenGUI Text follow the time of a intermission/RoundTime?

Asked by
TheePBHST 154
7 years ago

The problem I've been focusing on was mostly on trying to get this one text follow the intermission/RoundTime.

Here is the code

local countdownval = game.StarterGui.RoundInfo.Frame.Countdown.Num.Value
local countdown = game.StarterGui.RoundInfo.Frame.Countdown.Num
local gameRoundLength = 60
local intermissionLength = 10
local roundStartTime
local Map1 = workspace.MapNormal

local function active()
    local Map1Copy = Map1:clone()
    Map1Copy.Name = "MapClassicCopy"
    Map1Copy.Parent = game.Workspace
    roundStartTime = tick()
end

local function cleanup()
    game.Workspace.MapClassicCopy:Destroy()
end

Map1.Parent = game.ServerStorage
while true do
    active()

    repeat
        local currentTime = tick()
        local timeSinceGameStarted = currentTime - roundStartTime
        game.StarterGui.RoundInfo.Frame.Countdown.Num.Value = currentTime
        game.StarterGui.RoundInfo.Frame.Countdown.Text = game.StarterGui.RoundInfo.Frame.Countdown.Num.Value
        wait(0.25)
    until timeSinceGameStarted > gameRoundLength
    cleanup()
    wait(intermissionLength)
end

Here is the ScreenGUI GUI Preview

2 answers

Log in to vote
0
Answered by
Master_JJ 229 Moderation Voter
7 years ago

What I would do is put a IntValue in ReplicatedStorage and change its value to the intermission you want.

Then in the Local Script, I would write something like this:

local label = script.Parent
local intermission = game.ReplicatedStorage.Intermission

intermission.Changed:Connect(function()
    label.Text = tostring(intermission.Value)
end)

In a Server Script that will lower the intermission value I would do something like this:

local intermission = game.ReplicatedStorage.Intermission

repeat
    intermission.Value = intermission.Value - 1
until intermission.Value <= 1

I hope this helps. You could follow the same procedure for the round time.

0
This is probably the most popular way. Another way would be to create a RemoteEvent and whenever the intermission time is set you can fire all the clients and have it update from there. However that's a bit harder to do for a beginner like you seem. NewVoids 97 — 7y
0
And where do you want me to put the code of "Server Script" in? TheePBHST 154 — 7y
0
It should be in the Main Script that switches maps, teleporting players, etc. Master_JJ 229 — 7y
Ad
Log in to vote
0
Answered by
sammiya1 134
7 years ago

You could use an onchanged function. For example if this intermission/ round time gui uses and object value/ int value to store the countdown number then simply put a script in the text object or that screen gui to change the text as the intermisissions object value does and also display tht value changed to.

Answer this question