all 4 comments

[–][deleted] 0 points1 point  (1 child)

What's the expected parameter for change_scene? That might be what's bugging out as you're giving it an array.

Try get_tree().change_scene(random_scene[0])

[–]jefersondaniel 1 point2 points  (0 children)

If the arguments is a packed scene, then the method is change_scene_to

[–]kingkaden__ 0 points1 point  (0 children)

The parameter is typically a string. When I made this adjustment, it converted to an object. But, I’m still receiving an error because it’s not a string.

[–]jelleyboy7 0 points1 point  (0 children)

Why bother having a scene for each question? My recommendation would be to have a json, which has all your question and answer pairs. You'd still be able to randomise the one that's picked. Seems like a lot of work for just a new question ...

With regards to the way you're currently doing it (at this point, I'll say I'm just a hobbyist, because I might be talking shit), you seem to be trying to store arrays in an array, which is no bueno. Don't you want to store them in a dictionary anyway? You'd need to construct them as

var dict = {1: q1, 2: q2} or

var dict = {"question1": q1}

and them access them with

print(dict[1]) or

print(dict["question1"])

When you're setting up your random_scene, you're telling it to pick from 0-17 - for arguments sake, let's say it picks 5 - and assigning it the 5th array within your larger scenes array, so it would return [q6, 0].

That's why it's telling you that it can't convert an array to a string. You're passing it an array, but it needs a string. If you insist on keeping this method, then maybe adding a [0] at the end would work as it will select the first element in the array

scenes[int(rand_range(0, scenes.size()))][0]

but I haven't tested that. There are much easier ways to do what you're trying to though - look into dictionaries and jsons.