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

Attempt to perform arithmetic on a nil value?

if Counter.Text ~= "0" then
								Counter.Text = tostring(tonumber(script.Parent.Loot.Inventory.InventoryScroll:FindFirstChild(v.Name).Counter.Text) + 1)
							else

It gives me this error:

Players.Player1.PlayerGui.CoreGUI.Core:102: attempt to perform arithmetic on a nil value

1 comment

1

We may need the whole script.

1 answer

Counter.Text is not a number
How many did you say?

If you use tonumber on a string that has no implicit conversion to a numerical value, it will return nil. You will need to add a condition to catch that.

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