generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Creating your own methods?

Previous Thread :: Next Thread 
Hvxbyte is not online. 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 is not online. 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
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
17 Sep 2015 10:07 AM
Box.Parent = Parent; The Parent is a table.
Report Abuse
Hvxbyte is not online. Hvxbyte
Joined: 19 Aug 2015
Total Posts: 410
17 Sep 2015 10:12 AM
Thanking you!
Report Abuse
chimmihc is not online. 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 is not online. Hvxbyte
Joined: 19 Aug 2015
Total Posts: 410
17 Sep 2015 12:33 PM
Ah, all right.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image