Random Table Items not shown on Gui can someone help

hey guys I need help, I tried to put my random table item inside Guy and then clone it to the player GUI. and something went wrong, I don’t have errors and I can’t figure what happened

At first, glance, when you’re calling on your functions you’re sending the actual string not the property to be edited. Instead of trying to edit the text from the function, just return the randomly generated string and set the text from that.

buyerName.Text = NameRandom()

image

erroring not working

Have you changed all of your functions to return what you generated?

Using NameRandom as an example:

function NameRandom()
     return Name[math.random(1, #Name)]
end
1 Like

that worked, but here is one problem.

image

i want in this specific function it will choose 5 items and not 1 what can i do?

because after one loop its returning

can you help me please i just can’t understand how to make it choose 5

You can do something like:

function OrderRandom()
 ThingsToReturn = {}
  for i = 1,5 do
    table.insert(ThingsToReturn, OrderItems[math.random(1, #OrderItems)]
  end
  return ThingsToReturn
end 

This should return 5.

image

not working

What’s on line 47? (character limit)

Edit: Wait never mind, can you write local ThingsToReturn = {}, see if that works I’m stupid haha

the “end” before return is with red underline(after i put local)

function OrderRandom()
	local ThingsToReturn = {}
	for i = 1,5 do
		table.insert(ThingsToReturn, OrderItems[math.random(1, #OrderItems)])
	end
	return ThingsToReturn
end 

image

other error

Ok can you send me that part of the script please, as that’s what is returned from the function.

image

order.Text = table.unpack(OrderRandom())

no errors and the script works BUT its only giving me one item from the list and not 5

Are you able to print table.unpack(OrderRandom()) please as my results in my test code are:

yes in the print its printing 5 items but in the Gui its not Showing 5 Items

image

Ok well the easier alternative is:

local ReturnedValues = OrderRandom()
local Text = ""
if type(ReturnedValues) == "table" then
	for i,v in pairs(ReturnedValues) do
		Text = Text .. v .. " "
	end
end
order.Text = Text

Just this is more lines

1 Like