Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 28 Jul 2011 04:19 PM |
When I instance a new brick with a piece of code I type something like this:
Instance.new("Part", game.Workspace)
Since you can state the parent of the newly created part with the second argument of the function, then I was wondering if you could set the properties of the part right from the function. I think I've seen it before, but I'm not quite sure if it's possible. If it is, then how? :o |
|
|
| Report Abuse |
|
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 28 Jul 2011 04:37 PM |
Instance.new("Part", game.Workspace).Name = "Brick"
lol |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2011 04:43 PM |
| You can't set the properties using additional arguments, but you can edit one property by just indexing the return value of Instance.new, as Spectrumw showed. Other than that, you can either make a function that lets you do this, or you can edit the properties manually. |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2011 05:24 PM |
Setting one property (in addition to parent) can be done like this in one line:
Instance.new("Hint",workspace).Text = "Hint"
However, that cannot be a variable, so setting two properties (other than parent) requires a minimum of three lines:
v = Instance.new("Hint",workspace) v.Name = "Hint" v.Text = "Hint"
Also, if you want to remove it, you can't set another property using the Debris method. This is why a ForceField is short and sweet:
game:GetService("Debris"):AddItem(Instance.new("ForceField",workspace.BunnyBoy26),5) |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 29 Jul 2011 06:57 AM |
| Oh. I thought there was a simple way. D: |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2011 07:30 AM |
Make your own function for each object XD
function AddIntValue(name, val, parent) local v = Instance.new("IntValue", parent) v.Name = name v.Value = val end
AddIntValue("ROBLOX", 1337, Workspace)
|
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 29 Jul 2011 07:33 AM |
I think it would be easier to just make a variable of the new object and change it's properties from there. :P
local p = Instance.new("Part", game.Workspace) p.BrickColor = BrickColor.new('Really red') --etc
|
|
|
| Report Abuse |
|
|
| |
|