Variables wont update?

My Variables wont update after pressing onscreen button. So I cant change between building and destroying. Any ideas?

Are the variables not updating, or are the conditions for creating or destroying not being met?

Two ways to confirm :

  1. check the variable values in the debugger
  2. In each of actions where you change the value of the Build variable, also change the colour of an on screen object or the background (a different colour for each one). Then check that the colour change occurs when you expect it.

If the variable updates, then either the problem is with your conditions, or you are changing the variable somewhere else.

I created a text object that shows the state of the scene variable and it doesn’t update when clicking the buttons I made.

Put the text object creation in each of the mouse release events, and see if it appears. If it does, then there’s another event that alters the variable.

BTW, do you hide the mouse at all?

Actually, yes I did hide the mouse cursor. Does this affect it?

Yes. How can the mouse be over an object if it’s not there? I suspect you have a sprite instead of a mouse pointer. Check for collision with that sprite, and not use the mouse over condition

Unfortunately I did try that already and the variable still wouldn’t change.

It should work. Can you provide a screen shot of your updated events, and the events that move the pointer?

Here is a screenshot of all my events as well as the scene and game preview.
Ps. Sorry if its chaotic/messy. Initially I just messed around a bit since I was bored but started to like the feel of the game.

I tried something else with variables. I tried changing them with physical buttons on keyboard.

If 1 is pressed, change Scene Var String to “Planks”

If 2 is pressed, change Scene Var String to “Planks_Wall”


If I set it up so that if i press left mouse button and the scene var is Planks it builds planks
if its Planks_Wall it will build a wall.

However, if I press 2 the on screen text (that displays the var state) wont change. So it seems the var doesn’t change. But I can no longer build with normal planks, but can’t build wall either. If I press 1 again, I can build with planks again.

So it seems like the var is updating but also not updating.

I noticed that Gdevelop doesn’t like an underscore character in a Scene Var String. When I changed it from “Planks_Wall” to “PlanksWall” Everything worked