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
like this the script is executed only once. Try this:
wait() local plr = game.Players.LocalPlayer local magice = plr:WaitForChild("MagicEnergy") local maxmagice = plr:WaitForChild("MaxMagicEnergy") while true do wait () if magice.Value ~= maxmagice.Value then repeat wait(.5) magice.Value = magice.Value + 10 wait(.5) until magice.Value == maxmagice.Value end end
While true do
lets it run in a loop