(Solved) Hspd not set before reading

So I'm pretty new to GameMaker, I've been following some videos to help me grasp some things, but this one has me stumped. I'll post the error and then my code below.
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object skeleton:

Variable skeleton.hpsd(100003, -2147483648) not set before reading it.
at gml_Script_skeleton_move_state (line 3) - if (hpsd < maxspd) {
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_skeleton_move_state (line 3)
called from - gml_Object_skeleton_StepNormalEvent_1 (line 2) - script_execute(state);

So I have a skeleton that wants to move, but can't. Here's his create event:

Code:
/// Initialize the skeleton
hspd = 0;
vspd = 0;
maxspd = 5;
spd = 1;
jump = -10;
grav = 2;
state = skeleton_move_state;
obviously I've clearly set the variable hspd. This variable should be set upon the object's creation, which would be at the start of the game, correct?

So the state = skeleton_move_state, and when the game tries to read that script, it apparently says that hspd is not set, and thus crashes the game upon trying to move. Here is the script's code:

Code:
///skeleton_move_state
if (input.right) {
    if (hpsd < maxspd) {
        hspd += spd;
    }
    image_xscale = 1;
    sprite_index = spr_skeleton_run;
    image_speed = hspd/maxspd;
}

if (input.left) {
    if (hspd > -maxspd) {
        hspd -= spd;
    }
    image_xscale = -1;
    sprite_index = spr_skeleton_run;
    image_speed = hspd/maxspd;
}

if (!input.right && !input.left) {
    sprite_index = spr_skeleton_stand;
}
Input is an object that has StaticParent as its parent. StaticParent simply has the keys to press that make the character move etc.

I'm awfully confused by this and would very much appreciate some help :) I hope it's not something blatantly obvious that I missed, but I do hope it's an easy fix!
 
oh interesting, I get what you're saying but I don't exactly know how to fix that, could you tell/show me what to change?
 
Top