Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to add a variable to an object?

Hi, I want to add a variable to an object and I didn't know how. For Example:

local button = Instance.new("TextButton")
button.info = {}

It gives me an error.

1 answer

✓ Accepted answer

#You can't do that You can't add a variable ("property') to a Roblox Object without using values. Thats because Roblox protects the object where no new property can be set to it. #Use Values If you want to do it with values do the following:

  1. Create a Vlaue (Int, String, Bool, Object, etc...)
  2. Use a script to change the value:
local Value = VALUE HERE
Value.Value = NEW VALUE HERE
  1. Use a script to get the value:
local Value = VALUE HERE
Value.Value = NEW VALUE HERE

2 comments

0

Actually, you can do that. There's something new called 'SetAttribute'

0

oh

This discussion is preserved as it was. New answers, comments, and votes are closed.