Is there any difference between ':SetAttribute' and creating a Value to storage an information?

Hello guys!

I’ve had this doubt for a while now… Is there any difference between ‘:SetAttribute’ and creating a value to storage an information? I mean, on videos, I rarely see someone using ‘:SetAttribute’, so I think it is worse. But sometimes I use attributes and I can’t see any true difference.

I’m looking for differences such as: process speed, limitations, usage differences…

What I mean when I say SetAttribute:

local thing = script.Parent
thing:SetAttribute("Points", 50)

What I mean when I say “Value Storage”:

local thing = script.Parent
local Points = Instance.new("IntValue", thing)
Points.Name = "Points"
Points.Value = 50

Sorry if I posted it on wrong spot. I didn’t know where to post it.

Storing Data, there is no difference other than the fact that one is an instance and one is a property attached to an instance. That said, as values themselves are instances they take more data to store than an attribute. Attributes take less memory to store since it is just a Name and a value compared to Parent, name, value, type, uuid, etc. I do believe are better in that sense but really depends on what you are doing.

Hope this helps :smiley:

2 Likes

Roblox made an announcement 3 years ago when attributes was in beta they said that its faster and better in a lot of terms
New Studio Beta: Attributes! - Updates / Announcements - Developer Forum | Roblox
there is also this topic which is about object Values vs attributes based on what was said in the announcement
Attributes vs Value, which is better? - Resources / Community Tutorials - Developer Forum | Roblox

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.