I would make a calculator a letter, that I could calculate that a + b = 201 A = 100 B = 101
local Frame = script.Parent.Frame script.Parent.Frame.TextButton.MouseButton1Click:connect(function() local a = "100"local b = "101"local c = "102"local d = "103"local e = "104"local f = "105"local g = "106"local h = "107"local i = "108"local j = "109"local k = "110"local l = "111"local m = "112"local n = "113"local o = "114"local p = "115"local q = "116"local r = "117"local s = "118"local t = "119"local u = "120"local v = "121"local w = "122"local x = "123"local y = "124"local z = "125"local A = "100"local B = "101"local C = "102"local D = "103"local E = "104"local F = "105"local G = "106"local H = "107"local I = "108"local J = "109"local K = "110"local L = "111"local M = "112"local N = "113"local O = "114"local P = "115"local Q = "116"local R = "117"local S = "118"local T = "119"local U = "120"local V = "121"local W = "122"local X = "123"local Y = "124"local Z = "125" print(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) print(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) -- print(a..n..t..o..n..y) -- print("Hilter = "..H+i+t+l+e+r) -- print("Trump = "..T+r+u+m+p) -- print("Damigab3 = "..D+a+m+i+g+a+b+3) -- print("Antony = "..A+n+t+o+n+y) -- print("Melvin = "..M+e+l+v+i+n) -- print("Gabrielle = "..G+a+b+r+i+e+l+l+e) script.Parent.Frame.TextLabel.Text = Frame["5"].Text+Frame["4"].Text+Frame["3"].Text+Frame["2"].Text+Frame["1"].Text end)
You want to associate a letter with a number. i.e., given a letter, you can lookup a letter and get back a number. This is called a map.
Lua has two forms of maps:
Tables
local valueOf = { a = 100, b = 101, c = 102, ETC. ETC. Y = 124, Z = 125, } --use like `valueOf[someLetter]`
Functions
function valueOf(letter) if "a" <= letter and letter < "z" then return letter:byte() - string.byte("a") + 100 elseif "A" <= letter and letter <= "Z" then return letter:byte() - string.byte("A") + 100 end end -- use like `valueOf(someLetter)`
Given a word, you can just iterate over all of the letters in it and sum them up
local word = "hello" local sum = 0 for i = 1, #word do local letter = word:sub(i, i) -- the i-th letter of `word` sum = sum + valueOf(letter) end print(word .. " has letters that 'sum' to " .. sum)