Ability to change a ClassName in a Instance property

Howdy! As a Roblox developer, it is currently too hard and impossible to change an Instances’ ClassName of certain properties such as a Script, folder, a UI element or possibly changing it through a script without having to do extra procedures and measures to get a different ClassName of one instance.

At the moment, it’s been hard trying to switch through classes of an Instance of a parent(s) like a TextLabel as I need to use a plugin or some hacky method to get ones’ class like changing it from a Script > LocalScript, or another method through code like using Enum or a string with an = variable.

However, there are workarounds like Reclass by Elttob which works out fine and has an excellent motive for development, but having some sort of availability for developers to select and change would be somehow beneficial in many ways for class-switching.

A friend of mine @FilteredDev gave me an idea for this and a way to change a class of ones’ Instance ClassName through the Command Bar or a script:

Part = setmetatable({ClassName = "NotPart"}, {__index = Part})

It works, however, it would be beneficial as I’ve explained above with properties and scripts, it’ll be faster and more reliable to do rather than using setmetatable() and __index for certain situations as above.

With coding through a script, I purpose some ideas:

  • :GetService(): I’m not too familiar with the range of using Service, but having a Class service for ClassName would be beneficial along with changing it through properties.

  • Enums’; it’ll behave the same with the Enum class and index family-like UserInputService with a if / then statement or changing it for certain situations.

  • It’ll have custom properties for ClassName like what type of Class to change it through like an Enum or a string ("") to do the following:

Or:

local class = game.Workspace.Brick.ClassName
   
class.ClassType = Enum.ClassType.ModuleScript

if class.ClassType = Enum.ClassType.ModuleScript then
    print("Module!")
end

Those are some of my suggestions and ideas that would improve scripting through ClassName and changing it through properties and such, maybe not the scripting part a bit but properties, yes.

If Roblox is able to address this issue, it would improve my development experience, my development workflow, and how I manage my properties and instances across studio and in-game because it’ll be faster and more reliable to manage and change through properties and on a Script or ModuleScript or a Folder if possible through a script and such.

When a certain class like a Script which is server-sided is changed into a LocalScript as some instances’ need to change in certain procedures, the behavior which is altered would change as it’ll turn from a server-side component to a client-side component and script, it should also be changed to a similar class like scripts or a UI element depending on that specific class

Representation:

RobloxStudioBeta_GcaDkJ5gSa

It’ll never be inherited from an outside class or an abstract class like from a TextLabel => Script as mentioned by dibblydubblydoo and won’t do such behavior overall with this feature.

4 Likes

…Why?

Class is a natural property of an instance in any object-oriented environment. You’re not supposed to be able to change it, and it’s absolutely nonsensical to try.

Do you mean changing class as in destroying the old instance and creating a new instance of the desired class, and having all compatible properties of the instance simply transferred over (this makes sense), or do you mean changing the ClassName property so instances of a class appear as a different class (this makes no sense)?

7 Likes

I don’t understand what the benefit of doing this would be except to allow bad shortcuts.

4 Likes

Would the property allow you to convert an instance which is inherited from an abstract class such as BasePart to a class completely unrelated? Example: TrussPart => TextLabel.

If so, i could see the feature breaking, because users would probably try to do some absurd stuff.

1 Like

YES, the first one that you’ve said is what I’ve wanted the idea for similar to the plugin made by Elttob as certain classes can be changed to certain classes that are unique to them like UI elements and scripts as that would be terrible and stupid to do from a part to a script.

For scripts, it’ll still keep the code but the behavior and design would change like a client to a server-side script.

What my topic would have represented with similar classes:

RobloxStudioBeta_GcaDkJ5gSa

Good point on that Dekkonot and Nope on the second. As I’ve mentioned above with PeZsmistic reply, it’ll have to convert to something similar like a Script to a different type of script class, a UI element changing to another UI element, and nothing absurd with other properties.

I’ll edit my post to add some details related to the replies. :slight_smile:

1 Like