Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to keep a textlabel always updated?

(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!

2 comments

0

Put Points in the while loop

0

so more like: the local of the points is in the while true do?

2 answers

✓ Accepted answer
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.

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.

2 comments

0

thank you!

0

np

This discussion is preserved as it was. New answers, comments, and votes are closed.