How do I stop it from going over 100

You can write your topic however you want, but you need to answer these questions:
I want to prevent the number value from going over 100 when charging.

Sometimes it goes over 100 and it glitches the chakra bar that I created.

charge.OnServerEvent:Connect(function(Client,chargeType)
	if chargeType == "charge" then
	charging = true
	while charging == true do
		if Client.Character.Chakra.Value > 99 then return end
		Client.Character.Chakra.Value = Client.Character.Chakra.Value + 5
		wait(0.2)
	end
	end
end)

.

1 Like

make a max value,if that charka value equals max value then etc

IntValue or Variable can be used

1 Like

You should change the value to 100 if it exceeds the limit, then break the loop:

charge.OnServerEvent:Connect(function(Client,chargeType)
	if chargeType == "charge" then
	    charging = true
	    while charging == true do
		if Client.Character.Chakra.Value > 99 then
            Client.Character.Charka.Value = 100
            break
        end
		Client.Character.Chakra.Value = Client.Character.Chakra.Value + 5
		wait(0.2)
	    end
	end
end)

Alternatively, you can use math.clamp(x, min, max), which constraints x between min and max

4 Likes

something like

if chakra.Value > 100 then chakra.Value = 100