Unity-like Serialized Properties in Roblox Studio?

I was wondering if Roblox Studio has something similar to Unity in the way of serialized properties.

In Unity, you can mark a variable as serialized with the [Serializable] attribute.

image

This property then shows up as an editable field in the Unity Editor under that script or object. Not only is this extremely handy for editing values when iterating, Unity also allows you to bind specific types of objects (cameras, instances, other scripts) to these values in the editor.

So far in Roblox Studio I’ve just been using Attributes a la script.Parent.GetAttribute(). Attributes can be a little hidden away like this (and I also haven’t found a way to make attributes on scripts work specifically with roblox-ts yet) so editing these values in code ends up being faster most of the time. Noteworthy here is that this only works for the datatypes that attributes actually support.

For actually referencing objects in the tree, I think I’m stuck with finding by a combination of type and name? Is there a faster way to find objects? The Tag system could be used for this, but I was wondering if I could directly reference/link instances from the Roblox Studio interface instead, or otherwise quickly add a unique reference to another object in the tree.

I’m a little confused on what you mean, so if I am completely wrong let me know, and I’ll try to redo my reply


That’s basically just a value object, isn’t it (such as an IntValue or a StringValue)? You can then access it doing NAME = script.NAME.Value (NAME is just whatever you want to call it. The first name and the second name do not need to match up.


For setting the value to an object (‘bind specific types of objects to these values’), you can make use of an ObjectValue. Note however that you can’t control the type that is set as the value, beyond that it is an object.

1 Like

For setting the value to an object (‘bind specific types of objects to these values’), you can make use of an ObjectValue.

Oh, neat! ObjectValues are exactly what I was looking for. For some reason I thought these were only manipulable via scripts, but they work pretty much exactly the way I expect them to.

Thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.