Working on calculator, and encountered an error

So I was wondering how I could get past this error that is encountered when trying to add “1” to the end of a string in a TextBox to simulate a calculator. Here is my current LocalScript for the 1 button:

local contents = game.StarterGui.ScreenGui.Calculator.TextBox.Text
local button = script.Parent

function Clicked (mouse)
	contents=contents+"1"
	end
button.MouseButton1Click:Connect(Clicked)

And here’s the error:
Players.Derpee_Kirbee.PlayerGui.ScreenGui.Calculator.1.LocalScript:5: attempt to perform arithmetic (add) on string

You’re trying to add a string. Make sure you convert your data types to numbers by doing tonumber().

contents=tonumber(contents)+1

If you are trying to combine two strings follow the posts by @UnknownParabellum or @Vong25! This is just if you are doing a calculator and needing to add two numbers.

The error explains everything. What you are referencing is a string value, therefore you can’t do arithmetic, or math on strings. To add something to the end of a string you can concatenate it by using …

Try doing:
contents=contents.."1"

I think you are trying to concatenate 2 strings together. I would read this article on Combining Strings.

Thanks I’ve literally used concatenating before but I forgot about it lol. It still seems to not be functioning with this script in the 1 button:

local contents = game.StarterGui.ScreenGui.Calculator.TextBox.Text
local button = script.Parent

function Clicked (mouse)
	contents= contents .. "1"
	end
button.MouseButton1Click:Connect(Clicked)

Well, you are changing the text of a TextBox in StarterGui.

What do you mean isn’t that what I did?

You should be changing the TextBox in PlayerGui. Any changes made to StarterGui will not show unless if you reset.

Are you working with numbers? If so, don’t use strings.

@BestieBestGamerYT I don’t quite understand how that would work though. If I tried adding the number without a string, just the number, wouldn’t it try to solve an equation? I don’t want equations to be solved until pressing the = button.