xsticcydev / OfficialStyleScriptGuide

The offical guide of Style Script
1 stars 0 forks source link

Official Roblox Style Script Guide

https://www.roblox.com/library/6149121433/StyleScript

*(If you haven’t installed the plugin yet, install it first!)

Open the script editor: 1) Go to the ‘Plugins’ tab \ image

2) Click on the ‘Script Editor’ button \ image

3) The script editor should show up now \ image

Basic level

Create your first script \ Type:

   _btn:default
   bg:(255,200,200);
   end _btn:default

What this code does? \ It sets the background color of all TextButtons to the RGB color 255,200,200

How this code built up? \

The first line \

In the first line we have a definition. All definition starts with a _ symbol

After the _ symbol comes the class of the objects we want to style. In this case the TextButtons. Then why don't we write TextButton instead of btn? You can write both TextButton and btn. They are the same. At the bottom of this guide there is a list of all 'shortcuts' in StyleScript.

Next we have a : symbol and after that we have the state We have three states in StyleScript:

See an example of longer code

_btn:default
bg:(255,255,255);
end _btn:default

_btn:hover
bg:(255,200,200);
end _btn:hover

Do you understand this code? \ If don't, please read the guide again. \ If you do understand the code you can try yourself at the Advanced Level StyleScript

Advanced Level

(Warning: at advanced level styling we will use 'shortcuts'! You should read them before learning Advanced Level) \ Statements \ Yes, you heard it right! We can have statements in our styles! \ See an example:

_btn:0 $OFFSET_SIZE_X > 200
bg:(255,0,0);
end _btn:0

What this code does? \ It changes all of the TextButtons background color to the RGB color 255,0,0 IF the button's offset(pixel) size on the X axis is bigger than 200 \

Okay, what happens here? \ We will only focus on the first line. \ First, always write our statement after a $ symbol! \

How to build up a statement?

OFFSET_SIZE_X > 200

First we have our statement property. (see all statement properties at the bottom of the Guide) \ After we have the statement type. (see all statement types at the bottom of the Guide) \ And last we have the statement value(anything). \ So we check of the offset(pixel) size on the X axis is bigger than 200 then we approve the styles on the object. \ Statement properties

Statement types

HELP

RGB value syntax: (r(0-255),g(0-255),b(0-255)) (for any color modification) \ Vector2 value syntax: (x,y) (for size, position and anchor modification)