Coordinates from table

Hello,

i have a question: how to get x and y coordinates from a table randomly? i tried this, but its get me an error for y property

[lua]local coords = { {x=38,y=265}, {x=38,y=345}, {x=38,y=425} }

local function return_random()
local ranX, ranY
for i=1, math.random(1,#coords) do
ranX,ranY = coords[i]
end

return ranX,ranY
end

local a1 = display.newText (“TEXT”, 0,0, native.systemFont, 16)
a1.x,a1.y = return_random()[/lua]

any help is appreciated, as always) [import]uid: 16142 topic_id: 17652 reply_id: 317652[/import]

Hey darkconsoles,

I would make your return_random function look like this:

local function return\_random()  
 local r = math.random(1,#coords)  
 return coords[r].x, coords[r].y  
end  

Hope this helps!
Joe [import]uid: 8444 topic_id: 17652 reply_id: 67176[/import]

thanks firemaple) [import]uid: 16142 topic_id: 17652 reply_id: 67177[/import]