This script is meant to make two IntValues that are put into a player on spawn that represent the MAXMana and the Mana (for spells), if there is a better way to do this, please tell me, bear in mind I am a completely incompetent at scripting. (As you will find out).
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)-- When a Player spawns
wait(1)
local Mana=Instance.New("IntValue") -- New IntValue
Mana.Parent = workspace;
local MAXMana=Instance.new("IntValue")
MAXMana.Parent = workspace;
local level= script.Parent.Parent.Parent.Parent.Parent.leaderstats.Lvl.Value
MAXMana=level*20
Mana=level*20 -- I have other scripts that would take away Mana upon casting a spell
while true do
if MAXMana>Mana then -- If your MANA is below your MAX then replenish
wait(0.5)
Mana=Mana+1
end
end
while true do
if Mana>MAXMana then -- If a glitch/bug occurs and your Mana is ABOVE your MAX make it your max
Mana=MaxMana
end
end
end)
end)

4 comments
So where would I find the Mana and MAXMana in the game, to be used in other scripts? Thanks Btw!
Like their parents.
In studio the output said it needs a then at the end of line 17/beginning of line 18 but that then messed up the ends, could you help there? (Edit code block)
Edited code block, forgot to get rid of an end and forgot to add a then.