This is the script:
wait()
local plr = game.Players.LocalPlayer
local magice = plr:WaitForChild("MagicEnergy")
local maxmagice = plr:WaitForChild("MaxMagicEnergy")
if magice.Value ~= maxmagice.Value then
repeat
wait(.5)
magice.Value = magice.Value + 10
wait(.5)
until
magice.Value == maxmagice.Value
end
Like i said It works only if the player spawns with magice.Value being less than maxmagice.Value, but i need it to do the regeneration every time magice.Value is lower than maxmagice.Value

2 comments
Exactly what i needed, thanks!
No problem :)