Hello,
I’m trying to make a TextButton (RandomInputAdd) increase in numerical value by 1 increment per click. All is going well - every time I click the button, it increases - but the problem has arisen with my conditional statement (if RandomInputAdd.Text > 10 then RandomInputAdd.Text = 1). With this statement, I want it so that when the value of the text exceeds 10, it will reset back to 1.
Note that Chosen is a StringValue, and, since Lua can’t perform a comparison between that and a number, I need a way to convert it into a number somehow…
I’ve tried performing tonumber() functions, adding an IntValue to the TextButton, but I’m not too well knowledgable in this area.
local StarterGui = game:GetService("StarterGui")
local GUI = script.Parent
local RandomInputAdd = GUI.Frame.RandomInputAdd
local Possible = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
function Choose()
local IndexAdd = math.random(1, #Possible)
local ChosenAdd = Possible[IndexAdd]
RandomInputAdd.Text = ChosenAdd
print(ChosenAdd)
end
Choose()
RandomInputAdd.MouseButton1Click:Connect(function()
RandomInputAdd.Text = RandomInputAdd.Text + 1
if RandomInputAdd.Text > 10 then
RandomInputAdd.Text = 1
end
end)