Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can i convert this into a percentage its not working?!!

I'm trying to make a loading screen and capture the Percentage.

local ContentProvider = game:GetService('ContentProvider')


local Assets= ContentProvider.RequestQueueSize -- Gets the CURRENT Assets


while wait(.1) do
print(ContentProvider.RequestQueueSize/Assets*100 .. '%')
end

1 answer

What you are tying to is is concatenate a percentage sign onto 100, which is not logically valid.

Let's think about what a percentage is: it's really just another way to represent a fraction. When you get a 15/20 on a test, you got 75%. You can apply this same logic here. However we have to be careful. You want it to be 100% loaded when your request size is 0, therefore we need to subtract that number from the number of assets before we divide by the number of assets.

Why is that? Take a look at what this produces:
(5-5)/5 = 0/5 = 0
(5-0)/5 = 5/5 = 1
Try some different values and you'll see that this is the formula we want.

This is what this would look like in terms of your code:

while wait() do
    print((Assets - ContentProvider.RequestQueueSize)/Assets)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.