Is it possible to get numbers from a table and put them onto a textlabel?

Is it possible to get numbers from a table and put them on a textlabel? I tried to set the text as the table but it says in the output

Unable to assign property Text. string expected, got table

3 Likes

Use tostring()

tostring(number)
1 Like

image
Sorry lol. Is it possible to get the contents from it? like 1,2,3,4 and their values?

1 Like

Use a for loop to get the variable inside the table

2 Likes

I did that, It worked but like not how I expected it too, It got the number I was pressing but it didnt get the contents of the table. Here is a picture of the table btw
image

What I was hoping it’d be like is 000000000

1 Like

for loops have two variables, index and value. Use the Value instead of the Index

I tried both but it didnt work

Why not remove the replacement of the index? All you do is replace [1] with [“1”] and etc. I guess you can just replace that and make your table look like this:

local numbers = {
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0
}

Then just get the value and you should be good

1 Like

Try doing textlabel.Text = table.unpack(yourTable)

1 Like

Lemme ellaborate more.

Im making a phone system in my game


And what im trying to do is make it so the numbers at the top add up to what you have pressed.

Simple,

local finalString = ''

for index, value in pairs(number) do
    finalString.. = tostring(value)
end

yourLabel.Text = finalString

This will add the value to the string each time. Simply set the textLabel’s text to finalString.

Sorry to ask but what is finalstring in this instance?

The final string of all your numbers.

Oh, Its still not working then.

no, you need “…=” instead of “=” (you used finalString = tostring(value), it needs to be finalString…= tostring(value))

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.