How To Display Number

I have a mana script but I need someone to add something so it displays the number of mana that the character has. So if the mana that the player has is 10 the label will show 10 out of 100.

image

This is my mana script:

local bar = script.Parent.ManaFront

local char = game.Players.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")

local maxMana = hum:WaitForChild("MaxMana")
local mana = hum:WaitForChild("Mana")

mana.Changed:Connect(function()
	
	local change = mana.Value / maxMana.Value
	
	bar:TweenSize(UDim2.new(change,0,1,0))
	
	
	
end)

and Server Script Service mana script:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local hum = char:WaitForChild("Humanoid")
		
		local maxmana = Instance.new("IntValue")
		maxmana.Name = "Mana"
		maxmana.Parent = hum
		maxmana.Value = 100
		
		local mana = Instance.new("IntValue")
		mana.Name = "MaxMana"
		mana.Parent = hum
		mana.Value = maxmana.Value
		
	end)
end)
-- in the mana script
-- set manatext to the textlabel on the mana bar
manaText.Text = `{mana.Value} / {maxMana.Value}`

Can you put this into the script because I tried putting this in and Im pretty sure I did it wrong because it’s not working

local manaText = ... --path to mana textlabel
local bar = script.Parent.ManaFront

local char = game.Players.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")

local maxMana = hum:WaitForChild("MaxMana")
local mana = hum:WaitForChild("Mana")

mana.Changed:Connect(function()
	
	local change = mana.Value / maxMana.Value
	
	bar:TweenSize(UDim2.new(change,0,1,0))
	
	manaText.Text = `{mana.Value} / {maxMana.Value}`
	
end)

Couldn’t you just do

manaText.Text = change

instead of
manaText.Text = {mana.Value} / {maxMana.Value}

That would just spit out a decimal number, which is not what OP wanted.

Why would it do that?

mana.Value / maxMana.Value is just a number. / just denotes division.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.