How to make a number goes up / down smoothly?

Your script spam my console with that

1 Like

Is the script placed inside the requested TextLabel, and, is the TextLabel’s text made of numbers only?

1 Like

The text label have to contain letters.

1 Like

Remove that “+” then.
If it doesn’t work I will try to rewrite it.

1 Like

Then Ig you can create a NumberValue inside the TextLabel, named ‘CurrentNumber’, and try this:

local runService = (game:GetService("RunService"));
function Lerp(a, b, m)
	return a + (b - a) * m
end;

local SPEED = (15);
local numberGoal = (0); -- // Change it when needed to update the display

local currentNumber = (script.Parent:WaitForChild("CurrentNumber"));
function TextUpdate(dt)
	currentNumber.Value = math.ceil(Lerp(currentNumber.Value, numberGoal, dt * SPEED))
	script.Parent.Text = tostring(currentNumber.Value)
end;

runService.Heartbeat:Connect(TextUpdate)

Edit: Worked very well or me. It basically doesn’t rely on the TextLabel’s text, considering it has string-characters too, and not only numbers, therefore causing the issue you mentioned above. Instead, it relies on the ‘CurrentNumber’ value, which’s value is ALWAYS going to be a number, therefore not breaking the code.

Id guess the main reason theyre all erroring is because everyone is trying to assume what you havent explained, to be completely blunt about it

Can you explain EXACTLY what youre trying to do, exactly what your current setup is, and other important stuff like:
About how often is the value changing? How quickly do you want it to move? Etc
Anything that could be useful to getting your topic solved
Pictures are worth a thousand words

1 Like

I have a text label inside a surface gui.
I want the text label to change one by one to the value number.

I don’t know how to explain it

1 Like

If i remove the + it give me that

1 Like

The script spams errors because Heartbeat is a faster replacement of wait(). Please correct me if I am wrong

1 Like

.Heartbeat fires every time a Frame is fired, therefore, if average FPS is 60 fps, it’s going to print out
the error if it reoccurs constantly approximately 60 times a second.

2 Likes

When i change the value CurrentNumber the script don’t go to the value i set and reduce it

1 Like

I gonna make a gif of what i want

2 Likes

This is what i want
https://gyazo.com/9c0ef0bbac0bddaefa9e4e542a09a9a1

1 Like

Oh and the value is in the workspace in a folder. I don’t want the value to be animated. ONLY the text on the surfacegui.

1 Like
script.Parent.Text = tostring(Lerp(tonumber(script.Parent.Text),currentNumber.Value, dt * SPEED))
1 Like

image

You can use TweenService to tween the position of the GUI when the value is being updated

i don’t want to tween the position of the gui

1 Like

What does the output say, and where did you put the script?
Edit: You don’t need to change CurrentNumber, but numberGoal.

I put the script inside the text label