• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Problem with script

Thmask

Member
hello, i'm newbie with gml2, i'm having this problem
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object <undefined>:

Variable <unknown_object>.actualWeapon(100004, 0) not set before reading it.
at gml_GlobalScript_ChangeGun (line 2) - var wp_map = actualWeapon[weapon];
############################################################################################
gml_GlobalScript_ChangeGun (line 2)

i really dont know how solve it, only happens when i use the script, here's my code:

--------create--------
//BareHanded
actualWeapon[0] = ds_map_create();
ds_map_add(actualWeapon[0], "sprite", sPistol)
//BasicPistol
actualWeapon[1] = ds_map_create();
ds_map_add(actualWeapon[1], "sprite", sPistol2)

ChangeGun()

--------script (ChangeGun)--------
weapon = 0
var wp_map = actualWeapon[weapon];
sprite = ds_map_find_value(wp_map, "sprite");

i understand the problem is with var wp_map but i dont know how solve it.
 
D

Deleted member 13992

Guest
where are you declaring the actualWeapon array?
and where are you running the script?
are you running the script after declaration?
 

Nidoking

Member
I assume you're using GMS 2.3 and you didn't declare a function in your script. Declare a function in your script.
 
Top