We are looking for the player to be able to go to a random level on the press of a button. I don’t know if this is possible or how it would work. We haven’t don’t anything like this yet so this is new territory. Any help would be great, Thank you! [import]uid: 94237 topic_id: 20421 reply_id: 320421[/import]
This can certainly be done - what are you using to manage scenes? Director? Let me know and I’ll offer some specific advice.
Peach
[import]uid: 52491 topic_id: 20421 reply_id: 79989[/import]
Thanks Peach, Yes, I am using director, thanks for the help [import]uid: 94237 topic_id: 20421 reply_id: 80754[/import]
OK, for example let’s say you have 10 levels, named level1.lua, level2.lua, etc.
[lua]math.randomseed(os.time())
local function goLevel ()
randomLevel = math.random(1,10)
director:changeScene(“level”…randomLevel)
end[/lua]
That function would pick a random level from 1 to 10 and change scenes 
We use math.randomseed() to make the random number truly random.
Peach
[import]uid: 52491 topic_id: 20421 reply_id: 80785[/import]
do i have to state which levels are which number in main? also would this go under the eventlistener? thanks. [import]uid: 94237 topic_id: 20421 reply_id: 80956[/import]
No, if your level files are called level1.lua, level2.lua, level3.lua, etc. then that is all you need to do.
Just change math.random(1,10) to reflect the number of levels you actually have.
Eg, if you have 90, do math.random(1,90).
Will work fine 
Peach [import]uid: 52491 topic_id: 20421 reply_id: 80992[/import]
the level names have the numbers in them but they are spelled out like one and two. Would i have to change them to the numbers for that to work in this case?
[import]uid: 94237 topic_id: 20421 reply_id: 81168[/import]
also how do I connect the function to the button touch itself? [import]uid: 94237 topic_id: 20421 reply_id: 81175[/import]
Change them to level1.lua, level2.lua, etc - it’s much easier that way.
For the function to the button;
[lua]buttonname:addEventListener(“tap”, goLevel)[/lua]
Peach
[import]uid: 52491 topic_id: 20421 reply_id: 81184[/import]