Hvxbyte
|
  |
| Joined: 19 Aug 2015 |
| Total Posts: 410 |
|
|
| 17 Sep 2015 10:02 AM |
local Selection = { Create = function(Parent, Name, Color, Thickness, Transparency) local Box = Instance.new("SelectionBox"); Box.Parent = Parent; Box.Name = Name; Box.Color = Color; Box.LineThickness = Thickness; Box.Transparency = Transparency; Box.Adornee = nil; end }
I found out about it, and I thought it looked pretty cool, so I gave it a go by creating my own Create method which would then instantiate a SelectionBox, rather than repeating several code.
However, I get the error:
16:01:00.128 - Players.Player.Backpack.Game:8: bad argument #3 to 'Parent' (Object expected, got table) 16:01:00.129 - Script 'Players.Player.Backpack.Game', Line 8 - method Create 16:01:00.130 - Script 'Players.Player.Backpack.Game', Line 17 16:01:00.130 - Stack End |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 17 Sep 2015 10:07 AM |
object:Method(...) -> object.Method(object,...) Just make it into function(_,...) instead of function(...) since you're not using Selection for anything regarding OOP |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2015 10:07 AM |
| Box.Parent = Parent; The Parent is a table. |
|
|
| Report Abuse |
|
|
Hvxbyte
|
  |
| Joined: 19 Aug 2015 |
| Total Posts: 410 |
|
| |
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 17 Sep 2015 10:44 AM |
Yeah, using method syntax (:) passes the object being used first.
Muad'Dib |
|
|
| Report Abuse |
|
|
Hvxbyte
|
  |
| Joined: 19 Aug 2015 |
| Total Posts: 410 |
|
| |
|