Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why wont label text change to typed value?

Asked by 8 years ago

the label text on surface gui wont change to the number typed into the textbox, which has to be one of the numbers in the table, please help.

01local tbl = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99}
02plr = script.Parent.Parent.Parent.Parent.Parent
03char = plr.Character
04 vl = Instance.new("SurfaceGui", char.Torso)
05vll = Instance.new("Frame", vl)
06vlll = Instance.new("TextLabel", vll)
07vll.Size = UDim2.new(0,800,0,600)
08vll.Transparency = 1
09vlll.FontSize = "Size96"
10script.Parent.MouseButton1Down:connect(function()
11    for i,v in pairs(tbl) do
12        if script.Parent.Parent.NumberHere.Text == v then
13        vlll.Text = v
14    end
15    end
16end)

?

1 answer

Log in to vote
3
Answered by
theCJarmy7 1293 Moderation Voter
8 years ago

Ok, there are a few flaws in this. Firstly, your table gets cut off, secondly, there is this magic function called tonumber.

01local max = 20 --change this to the biggest number in the table
02 
03script.Parent.MouseButton1Click:connect(function()
04    local num = script.Parent.Parent.NumberHere.Text
05    if tonumber(num) then --check if it's a num
06        if tonumber(num)<=max then --check if it's under the max
07            vlll.Text = num
08        end
09    end
10end)
Ad

Answer this question