Help with loading text

I want to make a TextLabel that changes text over time to simulate a loading experience. This should be easy, however it just doesn’t work and gives no errors in console.
image

What I’d do is use a number value (inside the script), make a “for X = Y, Z” loop to iterate over this, add 2 to the value, then concatenate that value to the end of the text.

Ex.

local percent = 0
for X = Y,Z (where Y and Z are the limits to the loop) do
wait(.1)
loadlabel.Text = ("Loading… "… percent … “%”)
percent += 2
end

1 Like

Thank you, I will try something like that.

Is there a reason why you want to simulate a loading screen rather than create a working one? Otherwise @aaltUser’s idea will work.

1 Like

Yes, as it just needs to load for enough time to load all the textures and meshes.

Use :LoadASync() or whatever the function was called.
I haven’t had the need for using it, but I’ve seen it used in many loading screens that’ll actually track loading progress.

Link: PreloadAsync

1 Like

I implemented this, however there seems to be a line under “X,Z”. Upon checking console, nothing comes up. (And it doesn’t work)
image

(For context this is in a LocalScript)

Y,Z are meant to be numbers, replace them.

Basically how many times you want this loop to iterate over. (I’d set Y to 0 and Z to 50)

1 Like

I am sorry but I think he referred to them as placeholders.

Try changing X to percent, Y to 1 and Z to 100.

1 Like

Lol, I’m stupid. Thank you so much!

An easier way you can do this would be this.

for i = 0,100,2 do 
     wait(0.1)
     loadlabel.Text = ("Loading... " .. i .. "%")
end

What this does is eliminate the need for the variable and uses the number from the for loop which will iterate through from 0 to 100 at a step of 2, which you could then use to represent the percentage.

1 Like