Problem with loading screen counter

I’ve looked through the Dev Hub and i couldn’t find anything.
So i want to make a basic loading screen counter starting from 0% and going up to 100%.
Since i am not a really good programmer (and this helping topic i’ve created says it all), i want somebody to tell me what is wrong on my script.

local count = script.Parent.Text
count = "0%"

while true do
	wait(0.3)
	count = "1%"
	wait(0.3)
	count = "2%"
	wait(0.3)
	count = "3%"
end

Every time i start the game, the text is still 1%.

Screenshots if needed.

It stays the same.
Capture

Properties
image

Placement.
Ignore the placement of the Icons. I’m gonna change them later.

Thank you for helping a beginner <3

Try doing
count = count + 1"%"
if count == 100 then return end

It should work if im not mistaken

Your best bet would be to change this to a local script so it runs on the player’s computer. If you need to switch to a server script use remote functions. If you need any help please reply and I’ll see what I can do.

I first did it in a local script and got the same results as in a normal script. It’s still not counting.

like this? image

Try this:

local count = script.Parent.Text

while true do
if count ~= “100%” then
count = count + 1
else
—if the script reaches this point, the loading is complete.
end
end

You need to use two periods to combine strings. Like this:
count = count + 1 .. “%”

local label = script.Parent
local percent = 0

while true do
if percent == 100 then
—loading complete
else
percent = percent + 1
label.Text = percent…”%”
end
end

I tried both of the scripts you showed me and none of them work. The text is still 0%. I also tried to put strings just as @LoveTheBears101 told me and it’s still not working. To be more clear, all i want to do is to make it count from 0% to 100%. Once again i am so sorry for being such a beginner in scripting.

Try this

local count = script.Parent.Text
local counter = 1
while counter < 100 do
  counter = counter + 1
  count = counter.."%"
  wait(0.3)
end

image
And it’s still not working.
image
I don’t know if i am the one doing something wrong…

This is gonna break the script

Ah ok.

Ahhh yes! Thanks for the reminder - a friend told me that too.

Sorry for the confusion

im finding out a method now

You can use a for loop

local count = script.Parent

for i = 1, 100 do -- loop from 1 to 100
  count.Text = i .. '%' -- concatenate the number with a "%" character
  wait(0.1) -- wait a bit
end
3 Likes

It isn’t working because when you’re setting the variable
“local count = script.Parent.Text”
You’re just assigning the string of script.Parent.Text to the variable count
You’re not assigning count to the property
This should work:


for count = 1, 100 do
	wait(0.3)
	script.Parent.Text = count .. "%"
end
1 Like

Nvm, you were ahead of me lol GG

1 Like

Yay it works. Thank you sooo much!

Hey!

Im back!

Although you already have a solution, I’d recommend watching a few for loops and while loops tutorials!

This will help in the future!

1 Like