Mana = Stamina
My “MaxMana” is 100
My “Mana” is the same as the “MaxMana”
My RegenMana is 3
I want my Regen to stop until 100 is that it does not exceed over 100
Mana = Stamina
My “MaxMana” is 100
My “Mana” is the same as the “MaxMana”
My RegenMana is 3
I want my Regen to stop until 100 is that it does not exceed over 100
Just add if statement?
if Mana.Value > 100 then
Mana.Value = 100
end
Add check after increase.
Okay thanks but I have another problem it’s my bar it exceeds
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()
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)```
clamp the size between 0 and 1
script.Parent.Bar:TweenSize(UDim2.new(change, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.2)
here?
Strange, should have worked.
(klsakjgkldajkjgkjaklkgklaklgk)
It’s just that my bar goes beyond the limit of the mana bar
with that check you still get 100+ mana
when you calculate the new value of mana.
if that value goes over 100 it needs to be capped at 100.
then you need to update the status
How I can make an uptade status
Mana.Changed:Connect(function(currValue)
local change = currValue / (MaxMana.Value)
script.Parent.Bar:TweenSize(UDim2.new(change, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.2)
hpText.Text = math.round(currValue) .. "/" .. MaxMana.Value
end)
Maybe that?
Still not working you wanted all the scripts?
Sure ,maybe there will be something.
can you tell us the size of bar initially (before any changes) and the bar after being changed for us
i believe you will have to use math.clamp but I need more info on the sizes.
You can clamp the value.
math.clamp(YourMana,MinMana,MaxMana)
What script should I put it in and where?
show bar size after you lose and regain mana
wait(1)
local Mana = game.Players.LocalPlayer.Data:WaitForChild("BarStamina")
local MaxMana = game.Players.LocalPlayer.Data:WaitForChild("MaxStamina")
local hpText = script.Parent.Parent.Stamina
local MinMana = 0
local MaxMana = 100
Mana.Changed:Connect(function()
Mana.Value = math.clamp(ManaValue,MinMana,MaxMana)
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)
its meaning what “ManaValue” ?
I said that only for the example.