How can i make a script that makes frames visible as a value increases?

So I’m assuming you either;
a) Want the colors to change as the rpm increases goes,
b) Want something complex to appear as the rpm increases.

This should help you

Edit: I assume you know how to get the decimel but its just currentvalue/maxvalue

its more like more frames become visible as rpm increases

i have a circular frame already, I have seen that and will use it in future projects!

Well, this does pretty much the same thing, just upload the sprite sheet(s) it gives you and input the decimals. The module automatically sizes it for you

Edit: this makes it easier, better looking, and more optimized than manually make frames and the like invisible and visible

Btw, you would just upload the actual progress part (In full state) with a transparent background and put it inside the rest of the gui.

Also since it’s a half circle and not a full circle. divide the decimal by two and have the correct rotation

i see. i really want to stick with the circle that i have right now, but i should probably give spritesheets a go

1 Like
local RPMZ = {{4000,11}, {6000,19}}


local BestChoice = {0,0}
for i,v in pairs(RPMZ) do
	if math.floor(RPM) >= v[1] and v[1] >= BestChoice[1] then
		BestChoice = v
	end
end

local Names = {}
for x = 1, BestChoice[2] do
	table.insert(Names, "R"..x)
end
for c,p in pairs(rpmBar:GetChildren()) do
	local IsInTable = false
	for i,v in pairs(Names) do
		if p.Name == v then
			IsInTable = true
		end
	end
	if IsInTable then
		p.Visible = true
	else
		p.Visible = false
	end
end

Just saying that it would be a lot easier, manually make frames visible and invisible is finicky and hard, you probably have to individually label each one, and multiply the amount of segments by the decimal, and go through each comparing its name to the previously mentioned number, and if its under or equal to it make it visible and if not make it invisible.

Keep in mind you would be doing this at least a few times a second.

You pasted code with no explanation, could you tell us what it does? Plus it doesnt look like it accounts for if the lower the index the lower the value of the segment is.

I dont undersand what the BestChoice variable is supposed to be though. the rest is understandable

After reading the code, it looks like you’re still manually mapping out everything, but for each possible rpm value with the number of segments.

BestChoice is the best matching RPM Table for what the current RPM is, once that is found it takes it and creates a table with R1, R2 all the way up to BestChoice[2], then with that it checks all the frames and if the name of the frame is in the table it will make it visible

so i would add all of the rpm values to the RPMZ table?

yes, if you want R1 up to R10 to visible at RPM 1000 you would add {1000, 10}
local RPMZ = {{1000, 10}, {2000, 20}}

Its more of a concept that I thought of that you may be able to get working

i see. thank you for the help!

I dont wanna be the bringer of bad news or whatever, but instead of manually mapping out 3 different things, (rpm, number of segments, and segment names), you could only have to edit the names and have an accurate rpm while only having to change the name of each segment. This seems less time consuming in my opinion.

(See my post above)

A sprite sheet seems easier but…

both methods i have tried only result in this (my original method included):
https://gyazo.com/edcdca425d929abee47b0d8dac4b886a

edit: going to sleep, will pick up on this in the morning

RPM.rbxl (22.6 KB)

Can be modified to use percentages like this:

Now at 100 rpm it will make 11% visible, at 500 rpm 25% will be visible and so on…

local RPMZ = {{100,11}, {500,25}, {1000, 50}, {2000, 100}}


while true do
	wait()
	local BestChoice = {0,0}
	for i,v in pairs(RPMZ) do
		if math.floor(RPM) >= v[1] and v[1] >= BestChoice[1] then
			BestChoice = v
		end
	end
	
	local Names = {}
	for x = 1, math.floor((BestChoice[2]/100)*#rpmBar:GetChildren()) do
		table.insert(Names, "R"..x)
	end
	for c,p in pairs(rpmBar:GetChildren()) do
		local IsInTable = false
		for i,v in pairs(Names) do
			if p.Name == v then
				IsInTable = true
			end
		end
		if IsInTable then
			p.Visible = true
		else
			p.Visible = false
		end
	end
end

Here is a table based on your original post (Not percentages)

local RPMZ = { 
	{500, 1},
	{1000, 2}, 
	{1500, 3}, 
	{2000, 4}, 
	{2500, 5}, 
	{3000, 6}, 
	{3500, 7}, 
	{4000, 8}, 
	{4250, 9}, 
	{4500, 10}, 
	{4750, 11}, 
	{5000, 12}, 
	{5250, 13}, 
	{5500, 14}, 
	{5750, 15}, 
	{6000, 16}, 
	{6250, 17}, 
	{6500, 18}, 
	{6750, 19}, 
	{7000, 20}, 
	{7250, 21}, 
	{7500, 22}, 
	{7750, 23}, 
	{8000, 24}, 
	{8250, 25}, 
	{8500, 26}
}