GML I'm new to programming and need some help.

Discussion in 'Programming' started by OriginalGrim, Dec 6, 2018.

  1. OriginalGrim

    OriginalGrim Member

    Joined:
    Aug 22, 2018
    Posts:
    19
    I'm trying to make a textbox appear when I get close to an NPC but when I get near it and press E it crashes

    Here's the code I did I'm sure I screwed up, I just can't find out how.

    if distance_to_object(obj_player) <= 5 {
    if keyboard_check(ord("E")) instance_create_layer(100, 100, TextLayer, obj_textbox)

    }


    ___________________________________________
    ############################################################################################
    FATAL ERROR in
    action number 1
    of Step Event0
    for object obj_parent_NPC:

    Variable obj_NPC_Bob.TextLayer(100021, -2147483648) not set before reading it.
    at gml_Object_obj_parent_NPC_Step_0 (line 34) - if keyboard_check(ord("E")) instance_create_layer(100, 100, TextLayer, obj_textbox)
    ############################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_Object_obj_parent_NPC_Step_0 (line 34)


    I have the code attached to a parent NPC object so that this will aply to any NPC I make.
     
  2. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,198
    The error is saying that TextLayer does not exist. If this is the name of a layer you just need to put it in quotes, otherwise it thinks TextLayer is a variable.
     
  3. OriginalGrim

    OriginalGrim Member

    Joined:
    Aug 22, 2018
    Posts:
    19
    Thanks I can't believe the problem was so simple.
     
    obscene likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice