Creating an observable object container that can hold any data type

Godot Version

godot-4, gdscript 2d

Question

How do i resolve this error that i am trying to assign a data type float to an object with base type Nil?

I was trying to create a custom object that can hold any type of value that can emit a signal when its contents are changed.

I am very new to godot since ive very recently moved from roblox.

You haven’t initialized Current anywhere in your code, so it’s value is null at the line where the error was reported.

ohh so i cant just set it to a type and leave it empty on the numberscale class?

You can, but you need to check if an actual object is there before trying to access its properties, or create the default object. If you don’t create the object as a part of NumberScale’s initialization, then it makes no sense to set its properties in NumberScale’s constructor.