Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is the value error popping up and how do I fix it?

Hey, guys so I am making a XP Gui and I am having a bit of a problem here because every time I tell it to put inside of the text a value it keeps popping me up with this weird error.... Ok, this is the script and error:

ERROR

00:19:48.960 - Players.Player1.PlayerGui.StatsGui.XP Gui.ImageLabel.LocalScript:7: attempt to call field 'Value' (a number value)

00:19:48.961 - Stack Begin 00:19:48.961 - Script 'Players.Player1.PlayerGui.StatsGui.XP Gui.ImageLabel.LocalScript', Line 7

00:19:48.962 - Stack End

SCRIPT

local player = script.Parent.Parent.Parent.Parent.Parent
local stats = player:WaitForChild("Stats")
local xp = stats:WaitForChild("XP")
local level = stats:WaitForChild("Level")
local defense = stats:WaitForChild("Defense")
local tlabel = script.Parent.Parent:WaitForChild("TextLabel")
tlabel.Text = "XP: "..(xp.Value)"/"..(xp.MaxValue)
xp.Changed:connect(function()
	if xp.Value >= xp.MaxValue and level.Value ~= 15 then
	level.Value = level.Value + 1
	defense.Value = defense.Value + 10
	xp.MaxValue = xp.MaxValue + 20
	xp.Value = 0
	tlabel.Text = "XP: "..(xp.Value)"/"(xp.MaxValue)
	else
	tlabel.Text = "XP: "..(xp.Value)"/"(xp.MaxValue)
	script.Parent:TweenSize(UDim2.new(xp.Value/xp.MaxValue,0,.05,0), "InOut", "Quad", 5, true)
	end
end)

Thank you guys and I hope someone can help me out with this weird error...

~~ KingLoneCat

1 answer

✓ Accepted answer

Line 7, 14 & 16 you didn't concatenate:

--Line7
tlabel.Text = "XP: "..(xp.Value)"/"..(xp.MaxValue)

--Correct code:
tlabel.Text = "XP: "..(xp.Value).."/"..(xp.MaxValue)

--Line 14 & 16:

tlabel.Text = "XP: "..(xp.Value)"/"(xp.MaxValue)

--Correct code:
tlabel.Text = "XP: "..(xp.Value).."/"..(xp.MaxValue)

1 comment

0

Thank you so much but, I ran into another problem that I am posting a question about right now.... Somehow it works in-game but, not in-studio...

This discussion is preserved as it was. New answers, comments, and votes are closed.