Problem with State Machine implementation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By FelipeRattu

I made a simple FSM by swapping GDScript files in the same node, but every time i swap states too much it crashes and return this error:

ERROR: call: Condition ’ (ip + 5) > _code_size ’ is true. Breaking…:
At: modules/gdscript/gdscript_function.cpp:447

i made a script class with all the player variables and methods called “player_base”, this script class extends KinematicBody2D. So i made a script for every state that extends player_base, so when i press “UP” the player node changes it script to the Jump.gd script, after the player lands it changes back to Idle.gd.

here’s the code from PlayerAtributes, Idle and Jump:

PLAYER ATRIBUTES SCRIPT

extends KinematicBody2D

class_name player_base

func _init():
pass

func _physics_process(_delta):
	pass

IDLE SCRIPT

extends player_base

    func _init():
    	print("Idle")
    	set_process_input(true)

var possible_future_states = {
	"JUMP" : "res://StateMachinePrototype/Jump.gd"
     }

    func _input(event):
	if event.is_action_pressed("ui_up"):
		var next_state = possible_future_states["JUMP"]
		self.script = load(next_state)

JUMP SCRIPT

extends player_base

var possible_future_states = {
	"IDLE" : "res://StateMachinePrototype/Idle.gd"
	}
	

func _init():
	print("Jump")
	var next_state = possible_future_states["IDLE"]
	self.script = load(next_state)

The player node is a KinematicBody2D, I just wanna know whats wrong because it works for the first 2 or 3 times i press up then crashes and returns that error from the begining of this description.