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

How do i make a textlabel say the value of a numbervalue?

Asked by 4 years ago

I'm making a story game and I'm trying to make a countdown that shows how much time is left before the car leaves so I make a number value and it doesn't work.

2 answers

Log in to vote
0
Answered by
karlo_tr10 1233 Moderation Voter
4 years ago

This is code assuming that you want to change textlabel that is in Gui:

local Player = game.Players.LocalPlayer
local NumberValue = game.Workspace.NumberValue -- Path to NumberValue
local Countdown = Player:WaitForChild("CountDown").TextLabel -- Path to Textlabel

Countdown.Text = tostring(NumberValue.Value) -- Set it for the first time

NumberValue:GetPropertySignalChanged("Value"):Connect(function() -- Awoid while wait() do loop in this case as this is better on performance
    Countdown.Text = tostring(NumberValue.Value)    
end)
0
I think you might need to use a remoteEvent/Function for grabbing the NumberValue.Value, I've tried accessing value instances from localscripts before but it always returns 0. Z0ggg 20 — 4y
0
You don't if it's not stored in place client can't access karlo_tr10 1233 — 4y
Ad
Log in to vote
-1
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago

make the number value become the script's parent

change the number value parent to a text label

you can do this (script):

local numvalue = script.Parent
local text = script.Parent.Parent
local countdown = 20

while wait() do

numvalue.Value = countdown

repeat
    text.Text = numvalue.Value
    numValue.Value = numValue.Value - 1
wait until countdown == 0
end

sorry for the late response :P please mkar this as the correct answer is that helped you, ill check this out later, bye 8)

0
This is wrong at many levels, There is no reason to have countdown variable and numvalue(countdown should be handled by the server) also in case you want that, this countdown would be done within sec because there isn't wait() and you should decrease the value before applying it to text as it will be late 1 sec in your case. karlo_tr10 1233 — 4y
0
And you can't change textlabel with script(only if it's in surfacegui or bilboardgui inside workspace) karlo_tr10 1233 — 4y

Answer this question