How can I limit my mana regen to 100 and not exceed the maximum of 100?

65c648392e40c5dd2c9911a00c379945

42f40af637cee06faecd727ff4369581

wait(1)
local Mana = game.Players.LocalPlayer.Data:WaitForChild("BarStamina")
local MaxMana = game.Players.LocalPlayer.Data:WaitForChild("MaxStamina")

local hpText = script.Parent.Parent.Stamina

Mana.Changed:Connect(function()
    Mana.Value = math.clamp(Mana.Value,0,MaxMana.Value)
	local change = Mana.Value / (MaxMana.Value)
	
	script.Parent.Bar:TweenSize(UDim2.new(change, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.2)
	hpText.Text = math.round(Mana.Value) .. "/" .. MaxMana.Value
end)
1 Like

Ok thanks it works I think I understand