|
| 28 May 2014 06:09 PM |
Hi guys, I just wanted to know the "easy way" to set variable properties (like if a variable is cloning an Instance)
E.G: local v = Instance.new("Part") v.Parent = Workspace v.Size = Vector3.new(2,2,2) --Etc, etc.
How would I make the above example shorter, I've seen people do something similar to the following but I don't know if it's right.
E.G:
local s = Instance.new("Part") .Parent = player.PlayerGui .Size = player.PlayerGui
Here's my siggy... Done. |
|
|
| Report Abuse |
|
|
|
| 28 May 2014 06:10 PM |
Ignore the player.PlayerGui on the .Parent and .Size of the second example, I am tired and forgot to edit them. -_-
Here's my siggy... Done. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 28 May 2014 06:11 PM |
They're not literally "variable properties" but you can use the create function. Or something like this:
local createInstance = function(objectType, properties) local obj = Instance.new(objectType); for key, value in next, properties do obj[key] = value; end return obj; end;
localp art = createInstance("Part", {Parent = player.PlayerGui, Size = Vector3.new(2, 2, 2)}); |
|
|
| Report Abuse |
|
|
|
| 28 May 2014 06:26 PM |
^^^
There is already an existing method to doing it.
local Create = assert(LoadLibrary("RBXUtility")).Create; local Part = Create'Part'{ Parent = Workspace; Name="Part; }
|
|
|
| Report Abuse |
|
|
|
| 29 May 2014 03:22 AM |
@DrMath So I guess you could only use that for creating new instances, correct?
Here's my siggy... Done. |
|
|
| Report Abuse |
|
|