Trying to have the last element of the table and if it's the last element change it to 0. Trying to minus by the length of the table, so that it removes the last element.
bad argument #1 to 'remove' (table expected, got number)
I'm guessing where i'm going wrong is I am converting the table to a number when pressing the keypad?
local Self = TradeGui.Frame.Frame.Self; local selfPtsWorth = TradeGui.Frame.Frame.SelfWorth.PointsWorth;
local Foe = TradeGui.Frame.Frame.Opponent; local foePtsWorth = TradeGui.Frame.Frame.OpponentWorth.PointsWorth;
local selfSavedNum = {};
local foeSavedNum = {};
function Calculator(User, po############a######### for Index, Value in next, User:GetChildren() do
Value.MouseButton1Click:connect(function()
if Value.Name == "Back" then
local numLength = string.len(savedNum);
table.remove(savedNum, numLength);
pointsWorth.Text = (pointsWorth.Text .. savedNum);
elseif Value.Name == "Enter" then
print('pressed enter');
elseif tonumber(Value.Text) == "0" or tonumber(Value.Text) == 1 or tonumber(Value.Text) == 2 or tonumber(Value.Text) == 3 or tonumber(Value.Text) == 4
or tonumber(Value.Text) == 5 or tonumber(Value.Text) == 6 or tonumber(Value.Text) == 7 or tonumber(Value.Text) == 8 or tonumber(Value.Text) == 9 then
savedNum = tonumber(Value.Text);
pointsWorth.Text = (pointsWorth.Text .. savedNum);
end;
end);
end;
end;
Calculator(Self, selfPtsWorth, selfSavedNum);
Calculator(Foe, foePtsWorth, foeSavedNum); |