I tried using roblox’s health script to create a magic regen script using value’s but it seems to not work. Why is that?
local MAGICREGEN_RATE = 1/100 -- Regenerate this fraction of MaxHealth per second.
local MAGICREGEN_STEP = 1
--------------------------------------------------------------------------------
local Character = script.Parent
local magic = Character:WaitForChild'Magic'
--------------------------------------------------------------------------------
while true do
while magic.Value < magic.MaxMagic.Value do
local dt = wait(MAGICREGEN_STEP)
local dh = dt*MAGICREGEN_RATE*magic.MaxMagic.Value
magic.Value = math.min(magic.Value + dh, magic.MaxMagic.Value)
end
magic.Value.Changed:Wait()
end
Oh wait, check if the regen script still exists when you play the game. Scripts inside startercharacter model sometimes get destroyed if you dont put them in StarterCharacterScripts