How do I subtract or add a attribute value?

How can I subtract or add attributes values?

image

You would use Instance:SetAttribute() to set it.

There are no compound assignments with attributes unlike properties.

I tried set attribute but i want it to subtract its value from what it is.

States:SetAttribute("Stamina", States:GetAttribute("Stamina") - 1)

4 Likes

You would use Instance:GetAttribute() with the respective mathematical operator then set that as the new value of the attribute.

1 Like

What you’re doing here is trying to modify a value that won’t be saved anywhere. Get methods usually have a twin Set method, so use :SetAttribute()

1 Like

ohhhh ok thank you @COUNTYL1MITS @EmbatTheHybrid @TestyLike3

2 Likes

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