With the help of scripterhelpers I found out how to make a energy system. But i have no clue how to make a maximum number so that players cant go over the energy system's gui. Here is the part of the script
local player = game.Players.LocalPlayer
local Gui = script.Parent
local EnergyValue = script.Parent.EnergyValue
local MaxEnergy = script.Parent.MaxEnergyValue
game:WaitForChild(player)
Gui.Size = UDim2.new((EnergyValue.Value/MaxEnergy.Value),0,0,50)
EnergyValue.Changed:connect(function()
Gui.Size = UDim2.new((EnergyValue.Value/MaxEnergy.Value),0,0,50)
end)
while true do --here is the main part of the script
wait(0.1)
if EnergyValue.Value > MaxEnergy.Value then break end
end

1 comment
Try only enabling this for when the energy is less then the max (Energy.value < Max.value) Instead of trying to fix it after it passed thw maximum.