Need Help with Preforming Arithmetic on User Inputted Text inside a Text Label

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to UserInputed from inside a text Label like the Numbers and preform arithmetic on them and Make a working caculator

  2. What is the issue? Include screenshots / videos if possible! The Issue is that i can’t preform arithmetic on a String and i can’t perform arithmetic on only one Text input and i’m not sure how to get another Input so i can add them together

  3. I have tried google and rewriting my code I have also attempted using string.spilt and it was erroring and the error said

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local PlayerGui = game.Players.LocalPlayer.PlayerGui

local CaculatorFrame = PlayerGui.CaculatorUI.CaculatorFrame

local MathButtons = CaculatorFrame.mathStorer

local CaculatorDisplay = PlayerGui.CaculatorUI.CaculatorDisplay.Input

local NumberButtonsStorer = CaculatorFrame.NumButtonsStore

local EqualSign  = CaculatorFrame.EqualOperator

local MathHandler = require(game.ReplicatedStorage.ArthmiticHandler)

local NumbersOnDisplay = 0

local ArthmiticSignsOnDisplay = 0

local Text = PlayerGui.CaculatorUI.CaculatorDisplay.Input.Text
local splitNumber = Text:split("")

local Input1 = Text.split(tonumber(1))
local Input2 = Text.split(tonumber(1))

print(Input1)

print(Input2)

	for i,v in pairs(NumberButtonsStorer:GetChildren()) do
		if v:IsA("TextButton") then
			v.MouseButton1Click:Connect(function()
			CaculatorDisplay.Text = CaculatorDisplay.Text .. tonumber(v.Name)
			NumbersOnDisplay = NumbersOnDisplay + 1
				print(NumbersOnDisplay)
				if NumbersOnDisplay >= 10 then
					print("Error Numbers Overload")
					CaculatorDisplay.Text = "Error: Numbers Overload"
					wait(1.5)
				CaculatorDisplay.Text = ""
				NumbersOnDisplay = 0
					print("Numbers are at 0")
				end
			end)
		end
	end

for i,v in pairs(MathButtons:GetChildren()) do
	if v:IsA("TextButton") then
		v.MouseButton1Click:Connect(function()
			CaculatorDisplay.Text = CaculatorDisplay.Text .. tostring(v.Name)
			ArthmiticSignsOnDisplay = ArthmiticSignsOnDisplay +1
			
			print(ArthmiticSignsOnDisplay)
		if ArthmiticSignsOnDisplay >=6 then
			print("Error Arthmitic Overload")
		CaculatorDisplay.Text = "Error: Arthmitic Overload"
				wait(5)
				ArthmiticSignsOnDisplay = 0
				CaculatorDisplay.Text = ""
			end
		end)
	end
end


print(CaculatorDisplay.Text)
EqualSign.MouseButton1Click:Connect(function()
	if NumbersOnDisplay >=2 and ArthmiticSignsOnDisplay >=1 then
		print("Sucess")
		if string.find(CaculatorDisplay.Text, "+") then
			print("Adding")
			wait(5)
			CaculatorDisplay.Text = Input1 + Input2 -- Can't Add without another Input
		else 
			if string.find(CaculatorDisplay.Text,"-") then
				print("Subtracting")
				wait(5)
			CaculatorDisplay.Text = Input1 - Input2	-- Can't Add without another Input	
			elseif string.find(CaculatorDisplay.Text, "*") then
				print("Mutiplying")
				wait(5)
				CaculatorDisplay.Text = Input1 * Input2 -- cant add without another Input
			elseif string.find(CaculatorDisplay.Text,"/") then
				print("Dividing")
				wait(5)
				CaculatorDisplay.Text = Input1 / Input2 -- can add without another Input
			end
		end
	else
		print("Error please input Numbers and a Arthmitic Sign")
		wait()
		CaculatorDisplay.Text = "Error please input Numbers and a Operator Sign"
		wait(3)
		CaculatorDisplay.Text = ""
		NumbersOnDisplay = 0
		end
end)


Hi, so i got a problem where i want to add up the Numbers the User inputs inside this Text Label
image
But the problem is that this is just a text Label and it only has 1 Input and I need 2 inputs to preform arithmetic on the Numbers inputed inside the text Label. My Question is How can i get more than one Input from a TextLabel?

You would need to separate the numbers using something like string.split
However, it’s not as simple as that. The following code shows how you would solve the problem you provided, however, you will need to expand it drastically to allow for all of the other operators, as well as multiple operators in one problem.

local input = "3+1"
local splits = (input):split("+")

local output
for _, num in pairs(splits) do
	if (not output) then
		output = num
	else
		output = output + num
	end
end
print(output)