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

How to keep a textlabel always updated?

Asked by 4 years ago

(Ignore the tween position, they aren't part of the script that I'm asking..)

local TextLabel = script.Parent.Main.TextLabel
local Main = script.Parent.Main
local line = script.Parent.Frame
local MainVisible = 0, 0,0.447, 0
local LineVisible = 0.004, 0,0.522, 0
local MainUnv = -0.155, 0,0.447, 0
local LineUnv = -0.24, 0,0.53, 0
local Points = game.Players.LocalPlayer.leaderstats.Points.Value
wait(30)
Main:TweenPosition(UDim2.new(0, 0,0.447, 0))
wait(1)
line:TweenPosition(UDim2.new(0.004, 0,0.522, 0))

while true  do
    wait(0.5)
TextLabel.Text = Points.."$"
end

So as you can see here, the text depends on the value of your points. But, it updates once then it stops the update, is there a way to keep it updated? Thank you!

0
Put Points in the while loop Fad99 286 — 4y
0
so more like: the local of the points is in the while true do? fortesss7 40 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
local TextLabel = script.Parent.Main.TextLabel
local Main = script.Parent.Main
local line = script.Parent.Frame
local MainVisible = 0, 0,0.447, 0
local LineVisible = 0.004, 0,0.522, 0
local MainUnv = -0.155, 0,0.447, 0
local LineUnv = -0.24, 0,0.53, 0
local Points = game.Players.LocalPlayer.leaderstats.Points
wait(30)
Main:TweenPosition(UDim2.new(0, 0,0.447, 0))
wait(1)
line:TweenPosition(UDim2.new(0.004, 0,0.522, 0))

game:GetService("RunService").Heartbeat:Connect(function()
    TextLabel.Text = Points.Value
end)

You were referencing the value once, this should fix it.

Ad
Log in to vote
0
Answered by
Fad99 286 Moderation Voter
4 years ago
local TextLabel = script.Parent.Main.TextLabel
local Main = script.Parent.Main
local line = script.Parent.Frame
local MainVisible = 0, 0,0.447, 0
local LineVisible = 0.004, 0,0.522, 0
local MainUnv = -0.155, 0,0.447, 0
local LineUnv = -0.24, 0,0.53, 0
wait(30)
Main:TweenPosition(UDim2.new(0, 0,0.447, 0))
wait(1)
line:TweenPosition(UDim2.new(0.004, 0,0.522, 0))

while true  do
    wait(0.5)
local Points = game.Players.LocalPlayer.leaderstats.Points.Value
TextLabel.Text = Points.."$"
end

Now the Points is getting updated too! If it wasent in the loop it wont update the value.

0
thank you! fortesss7 40 — 4y
0
np Fad99 286 — 4y

Answer this question