How to change a Attribute Value?

Hello developers! I need some help trying to change a attributes value (string specifically) For more details heres my code below with messages.

local TestAttribute = script.Parent:GetAttribute("Text")

print(TestAttribute)
--It should print Hello but I really want to change the value in-game
--So heres my wierd and confusing attempt:
if TestAttribute == "Hello" then
	TestAttribute = "Hi"
end
--I tried my best I even read the Attribute Page but it wasn't that much information and I got confused.

If somebody could help then that would be great.

To change your attribute, you can do

Item:SetAttribute(‘Name’, “Value”)

1 Like
local TestAttribute = script.Parent:GetAttribute("Text")

print(TestAttribute)

if TestAttribute == "Hello" then
	script.Parent:SetAttribute("Text", "Hi")
end

Hope this helped. :grinning:

6 Likes

If only you googled for it Instance Attributes | Roblox Creator Documentation