This script is to display how much magic you have and change the size of the magic bar depending on the number (number value) but when your magic goes down it stays there and doesn't increase as it should

Can anyone tell me why

local player = game.Players.LocalPlayer

game["Run Service"].RenderStepped:Connect(function()
	local num = game.Players.LocalPlayer.Character.Magic
	script.Parent.display.Size = UDim2.new(player.Character.Magic.Value/player.Character.Magic.MaxMagic.Value,0,1,0)
	script.Parent.HP.Text = ""..num.Value.."/"..player.Character.Magic.MaxMagic.Value
end)


if player.Character.Magic.MaxMagic.Value > player.Character.Magic.Value then
	repeat wait(0.3)
		player.Character.Magic.Value = player.Character.Magic.Value + 3
	until player.Character.Magic.Value == player.Character.Magic.MaxMagic.Value
end
if player.Character.Magic.Value == player.Character.Magic.MaxMagic.Value then
	player.Character.Magic.Value = player.Character.Magic.MaxMagic.Value
end

1 comment

0

At the end of the function that decreases the magic when used, you could try setting the text again.