Adding to an attribute's number value with SetAttribute

Hello developers, I’m making this post to ask if it’s possible to add to a number attribute’s value using SetAttribute.

I’m making a mana system for my game and need to figure out how to add to the attribute value

Any help with this is appreciated as I need to figure this out in-order to finish my mana system.
Thank you, MBroNetwork/MasterBroNetworkPC.

1 Like

You could simply get the value of the attribute and add whatever number to it. I’m not sure if there’s a better way of doing this but it’d be as simple as:

local attValue = object:GetAttribute("AttributeName")
object:SetAttribute("AttributeName", attValue + 1)

Useful Documentation:
Instance:GetAttribute()
Instance:SetAttribute()

9 Likes

Thank you so much, this helped me out massively.
Feels like there should be a function for adding/removing to an attribute if it’s a number type.

:smiley:

True, I think it’d be nice if there was a way to do this all in one step but I’m glad this was helpful.

1 Like