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

O

OriginalGrim

Guest
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.
 

obscene

Member
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.
 
O

OriginalGrim

Guest
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.
Thanks I can't believe the problem was so simple.
 
Top