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()
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
that worked, but here is one problem.
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.
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
other error
Ok can you send me that part of the script please, as that’s what is returned from the function.
order.Text = table.unpack(OrderRandom())
no errors and the script works BUT its only giving me one item from the list and not 5
yes in the print its printing 5 items but in the Gui its not Showing 5 Items
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