Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local MainFrame = script.Parent
- local BtnHolder = MainFrame.BtnHolder
- local Input = MainFrame.Input
- local Output = MainFrame.Output
- local Btns = {
- ["*"] = BtnHolder["*"],
- ["+"] = BtnHolder["+"],
- ["-"] = BtnHolder["-"],
- ["/"] = BtnHolder["/"],
- ["0"] = BtnHolder["0"],
- ["1"] = BtnHolder["1"],
- ["2"] = BtnHolder["2"],
- ["3"] = BtnHolder["3"],
- ["4"] = BtnHolder["4"],
- ["5"] = BtnHolder["5"],
- ["6"] = BtnHolder["6"],
- ["7"] = BtnHolder["7"],
- ["8"] = BtnHolder["8"],
- ["9"] = BtnHolder["9"],
- ["C"] = BtnHolder["C"],
- ["="] = BtnHolder["="]
- }
- local Side = "Left"
- local Operator = ""
- local Num1 = ""
- local Num2 = ""
- MainFrame.Draggable = true
- Input.Text = ""
- Output.Text = ""
- Btns["C"].MouseButton1Click:Connect(function()
- Input.Text = ""
- Output.Text = ""
- Operator = ""
- Num1 = ""
- Num2 = ""
- Side = "Left"
- print("C: Cleared")
- end)
- Btns["0"].MouseButton1Click:Connect(function()
- if Side == "Left" then
- Input.Text = Input.Text .. "0"
- Num1 = Num1 .. "0"
- print("C: Added '0' to Left")
- elseif Side == "Right" then
- Input.Text = Input.Text .. "0"
- Num2 = Num2 .. "0"
- print("C: Added '0' to Right")
- end
- end)
- Btns["1"].MouseButton1Click:Connect(function()
- if Side == "Left" then
- Input.Text = Input.Text .. "1"
- Num1 = Num1 .. "1"
- print("C: Added '1' to Left")
- elseif Side == "Right" then
- Input.Text = Input.Text .. "1"
- Num2 = Num2 .. "1"
- print("C: Added '1' to Right")
- end
- end)
- Btns["2"].MouseButton1Click:Connect(function()
- if Side == "Left" then
- Input.Text = Input.Text .. "2"
- Num1 = Num1 .. "2"
- print("C: Added '2' to Left")
- elseif Side == "Right" then
- Input.Text = Input.Text .. "2"
- Num2 = Num2 .. "2"
- print("C: Added '2' to Right")
- end
- end)
- Btns["3"].MouseButton1Click:Connect(function()
- if Side == "Left" then
- Input.Text = Input.Text .. "3"
- Num1 = Num1 .. "3"
- print("C: Added '3' to Left")
- elseif Side == "Right" then
- Input.Text = Input.Text .. "3"
- Num2 = Num2 .. "3"
- print("C: Added '3' to Right")
- end
- end)
- Btns["4"].MouseButton1Click:Connect(function()
- if Side == "Left" then
- Input.Text = Input.Text .. "4"
- Num1 = Num1 .. "4"
- print("C: Added '4' to Left")
- elseif Side == "Right" then
- Input.Text = Input.Text .. "4"
- Num2 = Num2 .. "4"
- print("C: Added '4' to Right")
- end
- end)
- Btns["5"].MouseButton1Click:Connect(function()
- if Side == "Left" then
- Input.Text = Input.Text .. "5"
- Num1 = Num1 .. "5"
- print("C: Added '5' to Left")
- elseif Side == "Right" then
- Input.Text = Input.Text .. "5"
- Num2 = Num2 .. "5"
- print("C: Added '5' to Right")
- end
- end)
- Btns["6"].MouseButton1Click:Connect(function()
- if Side == "Left" then
- Input.Text = Input.Text .. "6"
- Num1 = Num1 .. "6"
- print("C: Added '6' to Left")
- elseif Side == "Right" then
- Input.Text = Input.Text .. "6"
- Num2 = Num2 .. "6"
- print("C: Added '6' to Right")
- end
- end)
- Btns["7"].MouseButton1Click:Connect(function()
- if Side == "Left" then
- Input.Text = Input.Text .. "7"
- Num1 = Num1 .. "7"
- print("C: Added '7' to Left")
- elseif Side == "Right" then
- Input.Text = Input.Text .. "7"
- Num2 = Num2 .. "7"
- print("C: Added '7' to Right")
- end
- end)
- Btns["8"].MouseButton1Click:Connect(function()
- if Side == "Left" then
- Input.Text = Input.Text .. "8"
- Num1 = Num1 .. "8"
- print("C: Added '8' to Left")
- elseif Side == "Right" then
- Input.Text = Input.Text .. "8"
- Num2 = Num2 .. "8"
- print("C: Added '8' to Right")
- end
- end)
- Btns["9"].MouseButton1Click:Connect(function()
- if Side == "Left" then
- Input.Text = Input.Text .. "9"
- Num1 = Num1 .. "9"
- print("C: Added '9' to Left")
- elseif Side == "Right" then
- Input.Text = Input.Text .. "9"
- Num2 = Num2 .. "9"
- print("C: Added '9' to Right")
- end
- end)
- Btns["*"].MouseButton1Click:Connect(function()
- if not string.find(Input.Text, "*") and not string.find(Input.Text, "+") and not string.find(Input.Text, "-") and not string.find(Input.Text, "/") then
- Input.Text = Input.Text .. "*"
- Operator = "*"
- Side = "Right"
- print("C: Added '*' to Operator")
- else
- print("C: You can't do that!")
- end
- end)
- Btns["+"].MouseButton1Click:Connect(function()
- if not string.find(Input.Text, "*") and not string.find(Input.Text, "+") and not string.find(Input.Text, "-") and not string.find(Input.Text, "/") then
- Input.Text = Input.Text .. "+"
- Operator = "+"
- Side = "Right"
- print("C: Added '+' to Operator")
- else
- print("C: You can't do that!")
- end
- end)
- Btns["-"].MouseButton1Click:Connect(function()
- if not string.find(Input.Text, "*") and not string.find(Input.Text, "+") and not string.find(Input.Text, "-") and not string.find(Input.Text, "/") then
- Input.Text = Input.Text .. "-"
- Operator = "-"
- Side = "Right"
- print("C: Added '-' to Operator")
- else
- print("C: You can't do that!")
- end
- end)
- Btns["/"].MouseButton1Click:Connect(function()
- if not string.find(Input.Text, "*") and not string.find(Input.Text, "+") and not string.find(Input.Text, "-") and not string.find(Input.Text, "/") then
- Input.Text = Input.Text .. "/"
- Operator = "/"
- Side = "Right"
- print("C: Added '/' to Operator")
- else
- print("C: You can't do that!")
- end
- end)
- Btns["="].MouseButton1Click:Connect(function()
- if string.find(Input.Text, "*") or string.find(Input.Text, "+") or string.find(Input.Text, "-") or string.find(Input.Text, "/") then
- if Operator == "*" then
- Output.Text = tostring(tonumber(Num1)*tonumber(Num2))
- elseif Operator == "+" then
- Output.Text = tostring(tonumber(Num1)+tonumber(Num2))
- elseif Operator == "-" then
- Output.Text = tostring(tonumber(Num1)-tonumber(Num2))
- elseif Operator == "/" then
- Output.Text = tostring(tonumber(Num1)/tonumber(Num2))
- end
- Side = "Left"
- Operator = ""
- Num1 = ""
- Num2 = ""
- print("C: Calculated")
- else
- print("C: You can't do that!")
- end
- end)
Add Comment
Please, Sign In to add comment