You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want to get the other number to display but it seems impossible with a click event because the first click on the buttons will override the second number input
-
What is the issue? Having issues with displaying a 2nd number on a text label
-
What solutions have you tried so far? I tried rewriting this code Mutiple times in different ways and I’m still stuck
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 CaculatorArthmitic = PlayerGui.CaculatorFrame.CaculatorArthmitic
local CaculatorButtons = PlayerGui.CaculatorFrame.CaculatorButtons
local NoInput = true
local CaculatorDisplay = PlayerGui.CaculatorFrame.CaculatorDisplay
for i,a in pairs(CaculatorButtons:GetChildren()) do
a.MouseButton1Click:Connect(function()
print(a)
CaculatorDisplay.CaculatorText.Text = a.Text
for i,b in pairs(CaculatorArthmitic:GetChildren()) do
b.MouseButton1Click:Connect(function()
print(b)
CaculatorDisplay.CaculatorText.Text = b.Text
local results = a.Text .. b.Text
CaculatorDisplay.CaculatorText.Text = results
-- How do get the second inputed number?
local CaculatorButtons2 -- this will overwrite because there can only be one set
end)
end
end)
end
Hello i have been working on this project all day trying to figure out how to input a 2nd number into the calculator text without it interfering with the first input any way to do this?
You can use ..
to combine two strings into one. Example: "hello " .. "world"
becomes "hello world"
Also, you misspelled “Calculator” on the UI.
That’s not the problem there problem is that i’m trying to combine two inputs with two events for both number 1 and number 2 but the problem is number 1 will overwrite the number 2 input thus you will only get one number not two i’m just trying to make it have two inputs but it’s like impossible with only one input
You are trying to make it so pressing “2” while already pressing “1” displays “12,” correct?
Try replacing
CaculatorDisplay.CaculatorText.Text = b.Text
with
CaculatorDisplay.CaculatorText.Text = CaculatorDisplay.CaculatorText.Text .. b.Text
I’m trying to make a caculator add the numbers 1 and 2 input together
like a regular calculator Ex 5+5
what i get
5 + – can’t input the second input value
Would you be able to record a GIF of how the calculator currently functions?
It currently functions with only a number but i know how to make it function with the arthritic value the problem just is that i can’t display other number when the button has been pressed again
I can’t tell if I have a correct understanding, so would you be able to record a GIF of you using it?
Yeah here’s a recording of the issue
robloxapp-20220502-2013469.wmv (482.0 KB)
Basically i’m just trying to get a 2nd input value with the clicked event again
You’re only using ..
in the part used for the arithmetic. Note how the number buttons are missing it: a.Text
and nothing else.
I know because i can’t add another number to a already implemented one again
Let me rewrite the script for you:
for i,a in pairs(CaculatorButtons:GetChildren()) do
a.MouseButton1Click:Connect(function()
print(a)
CaculatorDisplay.CaculatorText.Text = CaculatorDisplay.CaculatorText.Text .. a.Text
end)
end
for i,b in pairs(CaculatorArthmitic:GetChildren()) do
b.MouseButton1Click:Connect(function()
print(b)
CaculatorDisplay.CaculatorText.Text = CaculatorDisplay.CaculatorText.Text .. b.Text
end)
end