Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to add a variable to an object?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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

>

0
Actually, you can do that. There's something new called 'SetAttribute' royaltoe 5144 — 4y
0
oh Luka_Gaming07 534 — 4y
Ad

Answer this question