Problems with global variable

Hello I am new to gdvelop 5 I have about 1 day of game production and I have a question in my game that is like a quiz when I put the global points variable in the correct answer it works but even without having put the global points variable in incorrect option it counts the points this is a bug or an error made by me in the programming ???

screenshot of your events please

Ola o site diz que sou novo e não posso por fotos

Hello the site says I’m new and I can’t put photos!

But its here
Mas está ai

Sorry the image you uploaded can’t be seen, edit the post and correct the image

1 Like

Image link is fixed, @Viny wait one or two second for upload your image before valid the post.

Ok as I can see you only increment the variable pontos when

This is correct way to do it

First Touch or left is down
Trigger once
The cursor/touch is on b_correcto

but the actions order inside must be
Change pontos add 1
Change Scene
If not you are leaving the scene before the variable can be updated, i think.
What’s events you have on scene2?

1 Like

Hi hello i did what you Tell but doesnt works here the Photo

Let me see your scene elements are they overlapping or something? or even better if you don’t mind share the project and I’ll check it out.

To see the Photo touch on the Photo and you Will van see this

Here is It ,sorry about quality

Here I made some project like yours to demonstrate how to do it.

1 Like

Thank you for your support

Hello again i have download your project and did like you but have a litle problem with wrong option logo the photos

Have touched on resposta a but show the closebutton in resposta a and resposta b

Sure is because you missed the object variables inst_number = 0 and inst_number = 2
Those variables has to be present on the closebutton and other in the b_errado.

Every closebutton the checkbutton and all the answers background has an inst_number so you can do the check of its values then do stuff.

1 Like

Thank you it’s work Nice but now have problema with the parte of playbutton look.

And he dont Go to next quiz question and o have a question to you .
How to put the global variable in scene 2 but this with the score of scene 1 like If had 1 point in scene 1 Will be add in scene 2 to be 2 point in total of global variable “pontos totales”

Add the Tween behaviour to the start button.
For the levels delete the GameScene2 and just clone the GameScene and remaneit to GameScene2 then add the event in GameScene2 and do so to 3,4,5, etc
Don`t forget to remove the global variable initialization that just must be done in the GameScene not in the other, so the variable keeps it’s value.
I don’t have time right now this weekend i’m planning to make a whole game like this and saher the source, i’ll keep you updated.

1 Like

Thank you for you support .

Hi ,i Sorry how are you put the behaviour tween in playbutton ???
Couse when i try to put in to action "add object scale tween " he dont levar me do It .i mean into the list of action havent this i try to search but havent the action “add object scale tween” .