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

How would I get the TextLabel to sync (Meaning to copy the value of a IntValue) with the IntValue?

Asked by
TheePBHST 154
7 years ago
Edited 7 years ago

I already have this code answered

local Inter = Instance.new("IntValue") -- Creates the Value
Inter.Parent = game.Workspace
Inter.Name = ("Intermission")
Inter.Value = 10

while Inter.Value > 0 do
    wait(1)
    Inter.Value = Inter.Value - 1
end

(Which is this one) - AnsweredCodeForum

1.But my main question is to get the TextLabel to follow what the Value of the IntValue no matter what. (COMPLETE)

Here is the ScreenGUI that has the TextLabel

Image of TextLabel

2.Next thing is how would I repeat the process after a round is over? For example a round lasted for sixty seconds, then the IntValue will countdown to 10 (Which is the Intermission Value). After it counts, it does it again and again.

0
There are many better ways of doing this, but if you want you could just set the Inter.Value back to whatever your starting value is. Azmidium 388 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Was using RemoteEvent should have been using RemoteFunction

This is compatible with FilteringEnabled

In a Script in game.Workspace

IntermissionTime = 10
RoundTime = 60
IntermissionString = "Intermission: %s" -- can be any string, put %s where you want the time to be displayed
RoundString = "Time Left: %s" -- can be any string, put %s where you want the time to be displayed


GetTime = Instance.new("RemoteFunction")
GetTime.Name = "GetTime"
GetTime.Parent = game.Workspace

function GetTime.OnServerInvoke()
    local T = {}
    table.insert(T, String)
    table.insert(T, CurrentTime)
    return T
end

function CountTime()
    while CurrentTime > 0 do
        wait(1)
        CurrentTime = CurrentTime -1
    end
end

while wait() do
    String = IntermissionString
    CurrentTime = IntermissionTime
    CountTime()
    String = RoundString
    CurrentTime = RoundTime
    CountTime()
end

In a LocalScript in RoundInfo.Frame

repeat wait() until game.Workspace:FindFirstChild("GetTime")
while wait() do
    T = game.Workspace.GetTime:InvokeServer()
    script.Parent.Countdown.Text = string.format(T[1], T[2])
end
Ad

Answer this question