Hello, hope everyone is feeling great. How long is it going to take for SetAttribute() to be added by Roblox?
I think that Robloxâs teams mainly just have other priorities atm but eventually it will definitely be released. Thereâs a lot of stuff thatâs being held back from production at the moment, likely due to a lot of reasons (the ongoing epidemic, backlogs everywhere, server/code performance, avatar and lighting engine updates, etc, etc). There are tons of features Iâve been messing with, and theyâre all definitely planned to be finalized but itâs going to be a while is my guess.
Keep in mind that attributes have yet to be announced publicly and are not listed on the roadmap, documented, etc.
Are instance methods considered to be attributes? If so⌠how would you assign a method as an attribute to achieve Model:Test()
?
No attributes canât be directly indexed on the Instance. Theyâre very similar to Tags. You can use GetAttribute, SetAttribute, GetAttributes, AttributeChanged, and a couple others. They save on the instance like tags, and you can set them to basically any primitive you can think of excluding functions
, userdatas
(and Instances).
However, you can sort of achieve what youâre trying to do using metatables:
function wrapInstance(custom, instance)
local wrapped = newproxy(true) -- This creates a userdata you can change the metatable of. There's no way to make typeof return "Instance" without creating a custom typeof
local meta = getmetatable(wrapped) -- This will get the metatable of the userdata we created
meta.__index = function(self, index)
if custom[index] ~= nil and index:sub(1, 2) ~= "__" then
return custom[index]
end
return instance[index]
end
meta.__newindex = function(self, index, value)
local success, err = pcall(function()return instance[index]end)
if success or not err:find("is not a valid member of") then -- The property exists on the instance or causes a unique error
instance[index] = value
return
end
if typeof(custom.__newindex) ~= "function" and custom.__newindex then -- Allow the __newindex property of the custom table to be a table or userdata
custom.__newindex[index] = value
return
end
return custom:__newindex(index, value, instance) -- Call __newindex on the custom table and pass three extra arguments (index, value, and the original instance)
end
meta.__call = function(self, ...) -- This used to actually do stuff but recently this functionality was removed because it was unintended behaviour. (It has to do with how Roblox interfaces with lua)
return instance(...)
end
meta.__metatable = getmetatable(instance) -- This returns the "Locked" message
return wrapped -- Return the wrapped metatable
end
If you call wrapInstance
with a table of functions and properties it will return a new userdata which has those functions and properties. Any properties/functions you set with __
at the beginning will be nil when you try to get them on the wrapped instance. You can add a __newindex
function on the custom table (not in a metatable) to allow them to set custom properties (or even functions if you want) which will have one extra argument compared to the normal metamethod, the actual instance.
Basically the way it works is it just creates a new userdata to work with and uses metatables to decide what gets returned. It prioritizes things from the custom table, and uses stuff from the instance otherwise.
If you want to talk more Iâd suggest doing it through PMs though so this post doesnât keep getting bumped.
Any updates on when attributes will be released? Itâs been a long time since this blog
Well, I have no idea. Iâm not too sure the cause of the delay, but, Iâm hoping sometime soon as I still have code ready to use them. Theyâre definitely going to be a huge QOL improvement for me!
Is this feature still coming? The api was added over a year ago now and itâs still not enabled https://developer.roblox.com/en-us/resources/release-note/Release-Notes-for-408
Welp, this will make most of my serialization code useless. Yay! Not only this though, but with it you will be able to make serializers better than ever before!
Even if having a watermark saying âI own this game!â meant Roblox would take further action, exploiters on other sites would start releasing methods to instantly remove these tags.
All it takes is one exploiter with some developer knowledge to create an automated tag remover and then make it public on one of these off-site exploiter forums.
Personally I think setting attributes as watermarks for your game is a waste of time and Roblox probably wonât ever ban a user for having a watermark attribute that says they donât own it. If anything setting attributes is just like writing âWritten by WinterGoonsâ at the bottom of a script.
Edit: Didnât realize this topic was so old. My bad.
since luau, script source is never sent to clients, only luau bytecode, which does not include cmments, and only few exploits can decompile the bytecode to lua code