A question about attributes

Ok so my question is are attributes values?
Example Int Value
Are they values but you dont need to actually add the object into the game you just script it
also are they worth it to learn and use?

(also is this the right topic)

From what im seeing they are basically Value objects but there not objects and they can hold more types of Data is this correct or do i have this completely wrong?
I have never used these before and i just started looking at them so i dont really know if what im saying is true or not please let me know!

This post should help for most of the questions.

Nope they cannot hold object references. So less types. Their one and only weakness I believe.

Worth as it’s easier to manage and organize. No need to instance .new and parent like intvalues.

An example is getting values from a car model, normally there needs to be a folder called configuration in order to hold, store, and organize all those value objects. Now we can just do GetAttribute directly from the car model!

local carModel = Instance.new("Model")

local carConfig = carModel:WaitForChild("Configuration")
local speedValue = carModel:WaitForChild("Speed").Value

--Vs attribute just get the attribute
local speedValue = carModel:GetAttribute("Speed")

And then the Instance .new if you create new attributes

local carModel = Instance.new("Model")
--old number value way
local speed = Instance.new("NumberValue")
speed.Value = 100
speed.Parent = carModel
--vs attribute
carModel:SetAttribute("Speed",100)

Looking at it, it removes the chore of having to access the value by doing .Value

1 Like

There are a couple perks I quickly found:

  1. Since the attributes are embedded in the instance, it’s a lot easier to standardize types of instances. Less clutter too.
  2. Failing to find a StringValue returns nil and trying to get its Value spits out an error. GetAttribute returns nil for the value. One less critical bug!
4 Likes