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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: "Easy way" of setting variable properties

Previous Thread :: Next Thread 
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
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
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
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 is not online. 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
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
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
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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