Add Instance as a Valid Attribute Type

Is that not the case with any other attribute type like Vector3 or CFrame? I don’t see what problems it would cause, why would anyone expect to handle the cases of an attribute existing with nil or not existing at all differently?

2 Likes

Well the attribute is nil if there was no attribute found with the provided name. Nil is the default value for objects so this would become problematic.

3 Likes

Again, there’s no such problem right now with Vector3 or CFrame values, which could also be nil in the case of the attribute not existing, what cases would this be problematic specifically? what does introducing instances change?

2 Likes

Dude, you make a data type nil on an attribute? It always has a default value.

2 Likes

Programmatically, there is no problem with the current implementation of attributes that prevent Instances from being added. A nil value acts exactly the same as no attribute, but the setback is they wouldn’t appear the same in the properties widget because, well, no attribute is no attribute.

My only idea would be to simply allow instance attributes to be shown in the widget as “blank” (i.e., they don’t actually exist), and then in studio be able to set their value to whatever it is. The problem to this is probably how attributes are serialized in file places, which would need to be changed in order for studio to retain those attributes’ names between saves.

Personally, I would just add engine support for them already and worry about studio interfacing later because the majority of my use cases don’t revolve around having pre-set attributes anyways.

4 Likes

Then why not have no attribute as nil, and then a blank value is like, NoObject or something?

3 Likes

Instance, CFrame, Vector3, Color3, support for all of these unique data types would make attributes a thousand times more viable

4 Likes

Why isn’t there is a dropdown attribute type too?
Capture d’écran 2023-05-13 215212
image (2)
image (3)
image (5)
Here is what it can look like, I did my best to change the images!

Why this feature can be a great one:

  • create options more easier
  • no need to change script because when you will get the attribute it will return the Type you returned and the Name. (can had a value textbox too)
6 Likes

I assume the reason actually to be with how instances are serialised in the two specifications (it does them differently)

The XML format uses a debug id hash to refer to each instance

Meanwhile the binary format uses u32 based Referent objects, while I would say the best way to fix this would be to just compile the attribute string based on how you save (RBXM or RBXMX) but that feels a bit hacky since attributes have their own specification.

What I’m thinking of on that RBXM/RBXMX thing is having two unique type ids, InstanceBinary and InstanceXML which would be a u32 and string respectively, regardless, we’ll let Roblox decide.

5 Likes

Personally if I need to easily find a part associated with another instance I use a Weld (or some other joint) with Part0 (and only Part0) set to the target part and then use that weld to find that part, but this still feels like a very cheesy getaround and I wish we could just save instances inside an attribute

1 Like

Really is kinda crazy how this isn’t implemented yet - it feels like the whole point of adding the attribute system was to supersede (but not deprecate) the common practice of making a folder full of ValueBase instances, yet somehow we’re over 2 years since this feature was released and you still have to use ObjectValues and store JSON encoded strings for tables. This should not be at all a difficult feature to implement.

3 Likes

I think it might have something to do with how a nonexistent attribute gives the same value from :GetAttribute as an Instance attribute that is not set.

The delay says otherwise.

4 Likes

I believe its not added yet because, luau has only one type of “undefined”

For example, I set an attribute of an object to reference an object, How would I know if the attribute is saying nil or just completely nothing?

1 Like

Having to make ObjectValues well using attributes is very annoying, this would be awesome.

7 Likes

Why is ROBLOX not adding this? We need it!

7 Likes

Yeah, this would be extremely useful for many different reasons. Here’s hoping that Roblox adds this soon.

1 Like

Many people seem to want this, it’s a no-brainer to add tbh

1 Like

It really isn’t. Since things can’t have a default instance it would be impossible since when an attribute is nil it’s gone.

good idea and i support, but what about attribute dictionaries/tables

That wouldn’t be practical. That’s why bindables exist.