Problem with script for size bag

I made a script that sets the maximum size, but if you collect more than the Maximum size, the script does not make the bag size change to the maximum size.

game.ReplicatedStorage.ServerControllers.BagCheck.OnServerEvent:Connect(function(plr)
	if plr.Character:WaitForChild("Bag") then
		if plr:WaitForChild("level").Value <=5 then
			plr.Character:WaitForChild("Bag").MaxAmountStolen.Value = 6
			if plr.Character:WaitForChild("Bag").AmountStolen.Value >= 6 then
				plr.Character:WaitForChild("Bag").AmountStolen.Value = 6
				print("6 kilograms")
					end
				end
			end
		elseif plr:WaitForChild("level").Value ==6 then
			plr.Character:WaitForChild("Bag").MaxAmountStolen.Value = 9
			if plr.Character:WaitForChild("Bag").AmountStolen.Value >= 9 then
				plr.Character:WaitForChild("Bag").AmountStolen.Value = 9
				print("9 kilograms")
					end
				end
			end
		elseif plr:WaitForChild("level").Value >=7 then
			plr.Character:WaitForChild("Bag").MaxAmountStolen.Value= 12
			if plr.Character:WaitForChild("Bag").AmountStolen.Value >= 12 or plr.Character:WaitForChild("Bag").AmountStolen.Value >= 13 then
				print("> 12 kilograms")
				plr.Character:WaitForChild("Bag").AmountStolen.Value = 12
					end
				end
			end
		end
	end
end)

you can use math.clamp or math.min instead

math.clamp usage example

local minimum = 0
local maximum = 10
AmountStolen.Value = math.clamp(AmountStolen.Value,minimum,maximum)

math.min usage example

local maximum = 10
AmountStolen.Value = math.min(AmountStolen.Value,maximum)

use either one of those methods, and delete the if AmountStolen.Value >= 9 statements and other similiar ones

What to do with a local script that is driven by a bar?

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local findBag = character:FindFirstChild("Сумка")

if findBag then

local lvl = player:WaitForChild("level")

local mainFrame = script.Parent.Bag
local stolenBar = mainFrame.StolenBar
local statusStolen = stolenBar.Status
local bar = stolenBar.Bar

local amountStolen = findBag:WaitForChild("AmountStolen")
local MaxamountStolen = findBag:WaitForChild("MaxAmountStolen")

while task.wait(0.05) do
		statusStolen.Text = amountStolen.Value.."/"..MaxamountStolen.Value.." кг."
		bar.Size = UDim2.new(amountStolen.Value/MaxamountStolen.Value,0,1,0)
		if lvl.Value <=5 then
			MaxamountStolen.Value = 6
		elseif lvl.Value ==6 then
			MaxamountStolen.Value = 9
		elseif lvl.Value >=7 then
			MaxamountStolen.Value = 12
		end
	end
end
if findBag then
local amountStolen = findBag:WaitForChild("AmountStolen")
local amountStolen2 = findBag:WaitForChild("AmountStolen").Value
local MaxamountStolen = findBag:WaitForChild("MaxAmountStolen").Value

amountStolen.Changed:Connect(function()
	print("SENT")
	game.ReplicatedStorage.ServerControllers.BagCheck:FireServer(MaxamountStolen)
	end)
end