1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 [SOLVED] DoAdd :: Execution Error at draw+text

Discussion in 'Programming' started by Kleber_Ferreira, Jan 23, 2020.

Tags:
  1. Kleber_Ferreira

    Kleber_Ferreira Member

    Joined:
    May 13, 2019
    Posts:
    6
    The error below occurs when I run the game. I want to draw the score to the screen with the word Score before it. Drawing just the score variable to the screen shows no problem, adding the "Score: " string before it is causing the trouble and I don't know what's up.

    FATAL ERROR in
    action number 1
    of Draw Event
    for object obj_joystick:

    DoAdd :: Execution Error
    at gml_Object_obj_joystick_Draw_0 (line 3) - draw_text(scoreX, scoreY, "Score: " + global.points);

    I've been using GMS for months and this never happened. I have always drawn strings + variables to the screen.
     
  2. BaBiA Game Studio

    BaBiA Game Studio Member

    Joined:
    Jun 20, 2016
    Posts:
    923
    Change this:
    Code:
    draw_text(scoreX, scoreY, "Score: " + global.points);
    to this:
    Code:
    draw_text(scoreX, scoreY, "Score: " + string(global.points));
    Because the global.points is a number it is attempting to use addition (as in maths) to add the value of the global.points to a non-number "Score: ".
     
    Kleber_Ferreira likes this.
  3. Kleber_Ferreira

    Kleber_Ferreira Member

    Joined:
    May 13, 2019
    Posts:
    6

Share This Page