The code below at the while loop will never run because the loop will never end.
Instead put the code below the loop inside the loop, this way the if statement will run and the counter should reset back to 0.
Hope this helps!
local text = script.Parent.Text
local counter = 0
while true do
wait(1)
text = text.."."
counter = counter + 1
if counter == 3 then
text = "Loading"
counter = 0
end
end
Just noticed that I forgot about the TextLabel.Text property… Thanks for pointing out!
local text = script.Parent.Text
local counter = 0
while true do
wait(1)
text.Text = text.."."
counter = counter + 1
if counter == 3 then
text.Text = "Loading"
counter = 0
end
end
I’m not sure if the text variable is a TextLabel or a Text property, so I’m guessing you have another variable for the actual text and the TextLabel.
Something like this:
local textLabel = script.Parent.TextLabel -- pointing to your TextLabel
local text = "A loading text" -- any string should do
while true do
wait(1)
textLabel.Text = text.."." -- Should change the text to "A loading text."
counter = counter + 1
if counter == 3 then
textLabel.Text = "Loading" -- Changes the text to "Loading"
counter = 0
end
end
local textLabel = script.Parent.TextLabel
local text = "Loading"
local counter = 0
while true do
task.wait(1)
textLabel.Text = text.."."
counter += 1
if counter == 3 then
textLabel.Text = "Loading"
counter = 0
end
end
If you mean adding a period 3 times then resetting once the counter hits 0, then it should be like this:
local textLabel = script.Parent.TextLabel -- pointing to your TextLabel
local periods = {".","..","..."}
local counter = 0
while true do
wait(1)
textLabel.Text = `Loading {periods[counter+1]}` -- String interpolation
counter = counter + 1
if counter == 4 then -- 4, due to the counter stopping at the 2nd item of the array
textLabel.Text = "Loading" -- Changes the text to "Loading"
counter = 0
end
end
local textLabel = script.Parent.TextLabel
local counter = -1
while task.wait(1) do
counter = counter + 1
textLabel.Text = "Loading"..string.rep(".",math.fmod(counter,3)+1)
end
also I recommend working with the output open to make it easier to debug (if you don’t already)