I need help with my meter

I am trying to make a simple meter.
Heres my needs.
I wanted so it would go up if the value is not less than the last value it previously had(Achieved).
It would not go down after it was less than the last value.
Code:

local P = game.Players.LocalPlayer:WaitForChild('Data')['ServerData']['Rage']
function Get(bool)
	repeat
		wait()
		local V = 1
		local lastval = 1
		local hasbeenset = false
		if script.Parent:FindFirstChild(P.Value) then
			for i = V,P.Value do
				if script.Parent[11].Visible == true then
					for i = 11,V do
						script.Parent[i].Visible = false
					end
				else
					if lastval ~= P.Value then
						if hasbeenset == false then
							for i = V,P.Value do
						     script.Parent[i].Visible = true
						     lastval = P.Value
						     hasbeenset = true
					        end
						elseif hasbeenset == true then
							for i = P.Value,1 do
							print(i)
						end
						end
					else
						for i = V,P.Value do
							script.Parent[i].Visible = true
							lastval = P.Value
							hasbeenset = true
						end
					end
				end
			end
		end
	until bool == true
end
P.Changed:connect(function()
	if script.Parent:FindFirstChild(P.Value) then
		local B = Get(false)
		if B == true then
			Get(true)
		else
			Get(true)
		end
	end
end)

The issue is it is not going down if the numbervalue was less than the last value it had.
I don’t want it so it skips a bar.
I want it to be smooth.
JK
There are 11 in total.
Let’s give a simple scenario.
Let’s say the last value was 6.
And the new value for the number value was 4.
It would not go down for some reason.
I have tried to restart my code, but this version of it is better, it just needs to go down whenever the number value is less than the last value.

2 Likes

Just a quick read through and forgive my ignorance, but in the last section:
local B = Get(false)
if B == true then
Get(true)
else
Get(true)
end
You are setting B to Get(false) then trying to call Get(true) whether B is true or true?

1 Like

There’s a reason for that.
It’s for testing purposes.

1 Like

Perhaps this is a the faulty line? V must be lower than 11 for the loop to work

1 Like

It’s the opposite, it must be higher than 11 for loop to work. As 11 is starting and V is number it will loop to.

2 Likes