Roblox Game Development/Changing Properties

From Wikibooks, open books for an open world
< Roblox Game Development
Jump to navigation Jump to search

Introduction[edit]

What you are going to learn:

Learn about common Properties for the class object called "Part" and how to use them.

We will learn about two common properties.

Transparency[edit]

Transparency is the clearness of a shape. The Property of Transparency is a Number Value. An example of this is the number 2. Any number for the Transparency property can be changed into any number property. However anything over the value of one would remain the same in the physical world as invisible.

Here is a small scale of Transparency:

The greater the value between 0 to 1, the more transparent the Part gets. The number 0 is related to the Part being completely visible to the user in a game. The number value 1 means that the Part would be Completely Invisible in the game.


Example Insert a Part inside Workspace if you're on Roblox Studio now please.


Let's say there is the class object called "Part" in your Workspace and we want to change the transparency of the Part. Here is how we do it:


game.Workspace.Part.Transparency = 1


This is the line of code we need to achieve what we want to be done.

game.Workspace.Part gives you access to the Part that is in Workspace. All you have to do is add on Transparency and set it's value to the number value "1" so it will become invisible.


Now run the script.


If it was successful you have completed learning about transparency.

Anchored[edit]

The Anchored property requires two Boolean values called true and false.


Example:

game.Workspace.Part.Anchored = true

The class object in workspace is set.

BrickColor[edit]

The BrickColor property requires hues or color names to be put in after "BrickColor.New"

Example:

workspace.part.BrickColor=BrickColor.new([Hue])