Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making Frames with the name "A10" and up invisible?

Asked by 6 years ago

Settings[Names].Value = 50

I am making a progress bar and so far. The bar is supposed to put in the percentage of the progress and remove the green bars with the name "A10" and up. Kinda like an incomplete progress bar.

But, I get with line 8 is "attempt to compare string with number", so I change it to strings and it says "attempt to index a nil value" or something like that.

What do I do?

Here is the code:

function ProgressBar(Names)
script.Parent[Names.."Percent"].Text = Settings[Names].Value .. "%"
local t = script.Parent[Names.."Bar"]:GetChildren()
local ConvertValue = Settings[Names].Value / 5
for i,v in pairs(t) do
local A_Num = string.sub(v.Name, 2)
if tonumber(A_Num) <= tonumber(ConvertValue) then
v.Parent["A".. tonumber(A_Num) > tonumber(ConvertValue)].Visible = false    
end
end
end 

1 answer

Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
6 years ago
Edited 6 years ago

If I am interpreting your code and what you are trying to do correctly, then I believe your only issue is that your are incorrectly indexing the progress bar. In your code, on line 8, you are concatenating your string with A_Num first, and then comparing that value (which is now a string) to the number ConvertValue.

To be honest however, I don't think you need to do this comparison at all. You could simply have:

v.Parent["A" .. A_Num]

and your code should work fine.

Simplifying further, you have a for loop which contains your indices i and values v, so you should just be able to use your value which already contains a reference to 'A12' for example, and end up with:

v.Visible = false

Anyways, I believe your problem should now be fixed, as long as I am interpreting the question correctly. Let me know if you have any further questions. Hope this helps!

Ad

Answer this question