Create an “ObjectValue” attribute

Another bump - pleaseeeeeeeeeeeeeeeeeeee add this

I’m trying to use attributes more in my coding to utilize user-friendliness, their replication efficiency and their compatibility with Streaming Enabled. But the major flaw is not being able to set an instance as an attribute.

2 Likes

Same. I also struggle to think of substantial barriers to adding the feature. I may be mistaken but given that objects are already properties, such as in constraints, I think most of the work is done already.

1 Like

The issue is the “initialisation state”. How do you define it on an Instance in the properties window.

The default state of the Instance property type is null, which conversely, undefines an attribute. For ObjectValue its not a problem because Value is a fixed property which handles null as expected.

2 Likes

Easiest solution would be to just make it scriptable only, like Enum attributes, or make it so you have to select an object on attribute creation.

1 Like

The staff member said there’re different solutions they’re considering. Since he didn’t specify what the different considerations actually are, we’re left to guess. Nevertheless, clearly there are multiple solutions, the engineers just need to agree on which one to employ.

1 Like

This is the main reason why I can’t use packages.

2 Likes

Attributes were added 2-3 years ago and they’re still missing this feature. What a shame

4 Likes

Bumping cause I need this so bad!

1 Like

just ran into this issue, and was appalled to see that it does not exist, would really be useful.

3 Likes

this is extremely useful, pls roblox add!!!

1 Like

Was looking into something similar, would be very grateful for this to exist.

2 Likes

bump! this would definitely be good

2 Likes

bump still needing this - :slight_smile:

2 Likes

This NEEDS to be added.

ObjectValues are a necessity in some cases to Packages, for example, which will cease auto-updates if users that wish to set up settings for Packages modify anything of that package excluding the attributes linked directly to the Package’s base Instance. A solution to this would be creating a string to directly loop through from a directory, splitting descendant names and running FindFirstChild() through each of them, let’s say “ReplicatedStorage.Modules.Shared.Config”, you’d have to remove all the dot operators via gsub I believe (haven’t run over the exact method recently) and iterate through, which is less efficient than directly using an ObjectValue

3 Likes

Bump, it’s almost 2x faster for script to retrieve attribute values than any instance value (the reference part), takes less memory (no instance required) and shorter to type (said in the original post).

1 Like

In terms of what Roblox could have done to implement this to begin with, they could have utilized adding a new Enum, or just adding the option to set more specific Enums, even past ObjectValue attributes (not sure yet). They could have done something like this:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local values = ReplicatedStorage.Values

local packageFolder = Instance.new("Folder")
packageFolder.Name = "PackageFolder"
packageFolder:SetAttribute("ValuesFolder", values)
packageFolder.Parent = ReplicatedStorage

local retrievedValuesFolder = packageFolder:GetAttribute("ValuesFolder")
print("Values Folder Name:", retrievedValuesFolder.Name) --> Values Folder Name: Values

-- Setting it to the default value where you can reassign different Instances:
packageFolder:SetAttribute("ValuesFolder", Enum.AttributePlaceholderType.ObjectValue)

-- Check the newly set attribute's value
retrievedValuesFolder = packageFolder:GetAttribute("ValuesFolder")

print("Values Folder Type:", typeof(retrievedValuesFolder)) --> Values Folder Type: EnumItem

-- Check the status of the value assigned so we know if the attribute has even
-- been created yet or not
if retrievedValuesFolder == Enum.AttributePlaceholderType.ObjectValue then
	print("It's a placeholder type!")
elseif retrievedValuesFolder == nil then
	print("The attribute was never created!")
end

You may not even need to rework the system, with it being like that. I don’t know, please let me know what you think!

Also, apologies, I didn’t mean to reply to you directly, @maxim01689.

It’s all fine

Well, you used typeof in your example code, it returns a string type (unlike type, it supports all roblox types aka vector3, etc…), which means enums are not needed :slightly_smiling_face: (unless, you want the new fashion way)

I think this is something components can solve, both Unity and Godot have them. For example, Godot has GDScript as their built-in scripting language. You can create a new script and then attach it to an node in the scene (in Roblox it would be an instance).

The only issue is how Roblox treats scripts, they don’t extend anything, but I am sure they could come up with something similar if they wanted to.

1 Like

that’d be something cool to see but i doubt roblox would implement something like this anytime soon if they did at all.

1 Like