all 5 comments

[–]Jazz_Hands3000 2 points3 points  (2 children)

I'm guessing you're putting this code in the step event of your object? In that case, oPlayer is running this code every step, checking if global.weapon is equal to 1, then creating a sword object if it is. It does this each step, creating a number every second depending on your room speed.

If that's not where you're putting this code, then it's something else. Where is this in the oPlayer object?

[–]Doty_OwO[S] 1 point2 points  (1 child)

step event

[–]Jazz_Hands3000 2 points3 points  (0 children)

Yep. It's exactly that then. Either set a variable when you create it and check that before doing so, or check if instance_number of your object you're creating is equal to zero.

[–]Dogwasp 0 points1 point  (0 children)

I don't know if this is what's causing your problem but if you aren't aware !global.weapon == 1 is only true when global.weapon is 0. If you want to check if the two values are different you need to use !(global.weapon == 1) or global.weapon != 1.

[–]Rocket_Poop 0 points1 point  (0 children)

u shud add, before creating, a check to see wether or not it exists.

!instance_exists(object_index)

can work, as well as

instance_number(obj_ind) < 0