I've been tinkering with the code I have, and I've simplified most of it to see if it would make things easier. Though unfortunately, all the tinkering and testing isn't fixing my problem.
I want the player to be able to swap guns as much as they want (even if it's the same two guns over and over). Whenever I swap the character's gun about 3-4 times, the ability to swap just disappears. I can't swap the guns any more, but I can still pick them up. This is becoming a slight hazard because I plan to have many guns in the future and losing the ability to swap will frustrate players.
Below I've posted some of the code that I've been using within a script and the collision events of the three guns I already have. Maybe someone here will be able to fix the problem.
scr_toss()
if weapon_1 = "Pistol_A" then
{object = instance_create(other.x,other.y,obj_pistol)
weapon_1 = "None"}
if weapon_1 = "Submachine_A" then
{object = instance_create(other.x,other.y,obj_submachine)
weapon_1 = "None"}
if weapon_1 = "Shotgun_A" then
{object = instance_create(other.x,other.y,obj_shotgun)
weapon_1 = "None"}obj_pistol
if keyboard_check_pressed(ord('X')) then
{
switch (weapon_1)
{
case "None": with(other)instance_destroy()
weapon_1="Pistol_A"; break;
case "Shotgun_A": scr_toss()
with(other)instance_destroy()
weapon_1="Pistol_A"; break;
case "Submachine_A": scr_toss()
with(other)instance_destroy()
weapon_1="Pistol_A"; break;
default: exit;
}
}obj_shotgun
if keyboard_check_pressed(ord('X')) then
{
switch (weapon_1)
{
case "None": with(other)instance_destroy()
weapon_1="Shotgun_A"; break;
case "Pistol_A": scr_toss()
with(other)instance_destroy()
weapon_1="Shotgun_A"; break;
case "Submachine_A": scr_toss()
with(other)instance_destroy()
weapon_1="Shotgun_A"; break;
default: exit;
}
}obj_submachine
if keyboard_check_pressed(ord('X')) then
{
switch (weapon_1)
{
case "None": with(other)instance_destroy()
weapon_1="Submachine_A"; break;
case "Pistol_A": scr_toss()
with(other)instance_destroy()
weapon_1="Submachine_A"; break;
case "Shotgun_A": scr_toss()
with(other)instance_destroy()
weapon_1="Submachine_A"; break;
default: exit;
}
}











