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.
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.
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.
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.
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…
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).
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!
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 (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).