Add the Ability to Add Custom Properties Manually

Brief Explanation

As of now, each class(or Instance) has it’s own unique properties/attributes, but, it would be nice if we were to be able to add our own, theoretically adding to the instance. This will help developers because we wouldn’t need to use extra lines of code to execute simple tasks.


How will this work?

There will be a button at the bottom of the properties tab that will ask you if you want to create a new property or not:
Capture
Then, once you click on it, it will bring you to another interface, naming the property, what value it is, etc.:


Value type is the type of value(string, int, number, adornee) the new property will be. Name is the name of the property, and apply global is if you want to apply this property to all instances of the same class(if set to true), and only local to the part(if false).


Step 2 of Creating a Property

One you do it, it will bring you to the script editor, where you will be able to script what the property does. For this example, consider these variables:

  1. Value type is an IntValue
  2. Name is DamageOnTouch
  3. Apply global is false(Meaning affecting this part only)
  4. Property added to a MeshPart

This is what it would look like:

Capture

As you can see, you can add more than one property. And you can edit the code with the “Edit” button.

The script editor will assume that this is an int value, which you can reference with a new variable Property. So, if we do print(Property) and the Property is 10 it will print 10. PInstance will be the reference to the Instance that the property will be added to.

So, let’s say the property was equal to 10, and I apply this following script to it:

local HitTimes = 0

PInstance.Touched:Connect(function(hit)
    local Humanoid = hit.Parent:FindFirstChild("Humanoid")
    if Humanoid then
        Humanoid:TakeDamage(Property) -- Humanoid takes 10 damage
        HitTimes = HitTimes + 1
        PInstance.Name = HitTimes -- Of course, you can still modify the instance
        print(HitTimes)
    end
end

Now, whenever the part is touched it will make the player take 10 damage, make the name of the object the amount of times it damaged a player, and print it out.


Why this?

This will dramatically shorten code work, because this code will be embedded into the property. no need to worry about scripting it anywhere else. Say goodbye to metatables for doing this. This will also make work faster because you don’t need to scroll through an endless amount of code to find one thing, and modifying it will be at ease.


Sneak Peek:

22 Likes

If you want these properties to be used in an actual game and not just studio you will need to move this to #platform-feedback:engine-features.

By the way attributes are going to be a thing which is basically a way to make custom properties.

https://developer.roblox.com/en-us/resources/release-note/Release-Notes-for-408

3 Likes

I don’t think there was any indication of attributes being editable within Studio, ignoring the fact you can run :SetAttribute in the command line.

Either way, actual properties would be better than attributes in my opinion — I really dislike the Java-esque getters and setters attributes use (as opposed to just having it be =).

9 Likes