I want to make a ... loading TextLabel for my plugin but it doesn't do anything. Here is my script...
local load = script.Parent local credits = script.Parent.Parent if credits.Visible == true then wait(10) credits.Visible = false end while true do load.Text = (".") wait(1) load.Text = ("..") wait(1) load.Text = ("...") wait(1) load.Text = ("") end
The credits is the menu and when it disappears.
Instead of repeating the same line of code you could use some useful Roblox functions to make it much easier. string.rep
concatenates 'x' times of a string together which then returns that string.
If I wanted to concatenate 'Hello' 3 times together, I could do:
local text = string.rep("Hello", 3) print(text) --Output: --HelloHelloHello
We can use this in the while-loop to form the animated ellipsis effect:
local count = 0 --start at 0 local text while true do text = "Loading"..string.rep(".", count) print(text)--for testing count = (count + 1) % 4 wait(1) end
On line 6, we use to calculate the count we're on by getting the remainder of count divided by 4 (Search the modulus operator for more).
The reason your Text may not be changing could be found by adding a few prints()
to debug what does run. Like inside the if-statement on line 5 or checking to see your variable paths are right.
Remember that the while-loop is infinite so you will need something to break it.
The finished script should look something like:
local loadLabel= script.Parent local count = 0 while true do loadLabel.Text = string.rep(".", count) count = (count + 1) % 4 wait(1) --eh end