New Studio Beta: Attributes!

I am really looking forward to this update. Looks promising!

@Neutron_Flow
The biggest one is that attributes support complex tables, and far, far more data types.
There are a few other benefits I thought of though:

  1. Performance & memory usage (Particularly network performance I think will be an important difference, but also CPU performance)
  2. They’re generally a lot easier to use in code
  3. They’re a lot more compact in your save file meaning your save file will be a lot smaller

I absolutely agree that value instances still make sense in some cases, but, I personally think they should be deprecated. Value instances to me have always felt hacky and strange. But, that’s not to say I don’t think Value instances should never be used, sometimes deprecated features are still used and for good reason. Deprecating them doesn’t make them go away or anything. Generally I would expect them to be used somewhat like Configurations, where you maybe use a few Folder instances to specify options, or you might store your attributes directly on the model they’re a part of.

Maybe that’s just me lacking info about what your case is though, I’m sure you’ve got good reasons considering the amount of people I’ve seen saying the same thing about that.

3 Likes

Leaderstats is the only reason we use ValueBases 99% of the time

I should probably make a feature request for that.

Yikes! That’s not good then we need those Added/Removed events

actually it does, I’ve been testing it

I’m concerned because StringValue and Script.Source has this limit

3 Likes

THIS. IS. AMAZING!! I will be using this so much! Very, VERY good update

2 Likes

I’ve used them in the past but when I do I always opt for hash maps with instances as my keys as a better alternative, effectively botched attributes haha

(I do still use ObjectValues very frequently though, its often impossible to avoid them)

This… Is… AMAZING!!! However, I found a bug with it. I decided to play around with an IntValue, creating something called an All Purpose Value lol. When I playtest the game, everything in that value disapeers. I have no Team Create on or anything. It is just in an empty baseplate.

EDIT: I realized that I had properties in the script, not the IntValue I created.

Here is a real bug:
When i run this script with the value String set to “Hello World”, it comes out with this error:
image

1 Like

I just enabled the flag for this 1 hour ago and then this happens :slight_smile:

I wonder though. Compared to instance properties, how network efficient are attributes? I am working on a custom character system for an experimental game with 100+ players. I could set up a system which creates instances to represent stats, or I could just change attributes, but it all depends on how efficient they are.

To start - my gratitude is immense.
This is like re-inventing the wheel with a purpose.

It might be a bit of a stretch, but the ability for a descendant of an object with attributes to inherit them would be amazing. I’m thinking from the standpoint of a framework of ModuleScripts, or maybe I can set DataModel’s attributes to a ton of services and never have to use GetService ever again.

Furthermore, functions and other various data types (like objects and those detailed in this poll) should not be overlooked when it comes to support for attribute types. Attributes have us coming a long way from wrapping objects with metatables for custom properties, but what’s more powerful and more convenient than custom properties are custom functions.

I also hoped that Attributes would’ve worked in the same way to normal properties, where I could just say Part.CustomAttribute rather than Part:GetAttribute(“CustomAttribute”), but the difference is minimal, and the purpose for the underlying system is beyond my knowledge.

3 Likes

There are a few other benefits I thought of though

I didn’t say anything about the benefits of either; I have different use cases for each. For the most part, the reason for deprecating a feature is either that feature had some flaw that made unsafe to use or that feature is no longer useful. Since Values are still useful, they shouldn’t be deprecated.

And just to clarify: I am VERY excited for Attributes

I’ve literally been waiting patiently every single day for this post ever since the feature was announced. This is honestly an awesome change and I definitely can’t wait to see how it evolves into the future. Thanks, Roblox! :smiley:

1 Like

I don’t really understand the use cases of Values over attributes I suppose is the problem.

Fast and efficient replication of a fixed value type through its Value property. Attributes are really cool, but imagine handling 100+ Vector3s and CFrames every frame. I’d rather use a system that is better suited for that case.

That depends on how attributes are implemented.

1 Like

This is the perfect update for me! This will make the development speed of one of the games I’m currently working on be so much faster and feel way smoother since I felt like working with StringValues, BoolValues, etc wasn’t really fitting me due to how I have to call the value for it, so I had to resort so much to locals inside of scripts. Now I have a second option and I’m really going to enjoy it! Can’t wait for it to go out of beta stage. :+1: :+1: :+1:

Thank god they’re doing the widget version of Attributes! Will this support Instance object in future?

1 Like

Attributes are significantly faster and more memory efficient based on my testing. Value instances are bulkier than you’d think. Instances can take up a lot of memory, and I mean a lot of memory. I’ve used this to my advantage in the past both to prevent and detect saveinstance exploits. The problem beyond memory with instances is that accessing said instances is both slow and annoying to do in code. If you want it to be fast, you have to have a variable for every single value you use in the code, then you need to index Value for every single one. (And on top of that you have to type WaitForChild a million times if you want to be best practice) With attributes I believe its comparable to accessing a table, just through a function (so a bit slower than direct access).

2 Likes

Adding on to that, if you try and search for a specific attribute it doesn’t show, but then if you remove your search any attributes you had disappear until you click on the instance again.

1 Like

Oh my god the inclusion of NumberSequence in this is HUGE. Now just give us a built in function of NumberSequence to give us the value at a given time

1 Like

This has to be byfar one of the MOST OP features in roblox, We can literally do so much now. For example

Clouds Object doesn’t have a enable and disable function. We can add a attribute into it and save the last values registered before it was turned off
Same thing with atmosphere

We literally have a whole new world of saving and editing values in-game.

3 Likes

FINALLY! I’ve been waiting for something like this for MONTHS! Now I don’t need to spam my game with Values

1 Like

For anyone who’s against the JS-esque syntax, you can use a wrapper like this, though I wouldn’t advise it

local function attrWrapper(obj)
  local proxy = newproxy(true)
  local mt = getmetatable(proxy)

  mt.__index = function(_, k)
    return obj:GetAttribute(k)
  end

  mt.__newindex = function(_, k, v)
    obj:SetAttribute(k, v)
  end

  mt.__call = function()
    --bit yucky but it's the best we can work with
    return obj:GetAttributes()
  end

  return proxy
end

local wrapper = attrWrapper(workspace.Part)
wrapper.Data = "Hello World!"
print(wrapper.Data) --> "Hello World!"
print(wrapper()) --> {["Data"] = "Hello World"}
6 Likes