Type Annotation in Roblox Studio!

Ойындар

Type annotation can be greatly beneficial to use in your projects! It can improve the readability of your code, improves your coding efficiency, and it might even result in performance benefits if they are added in the future!
Ever wanted to learn Roblox Studio & scripting? Check out my course:
bit.ly/LuaScriptingCourse
Use code RBLX_DEV for 33% off!
Or check out my FREE course here!
linktr.ee/crusherfire
Timestamps:
0:00 Intro
0:20 Dynamically Typed Languages
0:35 Statically Typed Languages
0:54 Benefits of Type Annotation
2:10 Type Inferencing Modes
3:55 Parameter Type Annotation
6:00 Union Types
7:12 Type Refinement
7:59 Autofill
9:06 Variadic Types
9:41 Literal Types
10:55 Variable Type Annotation
11:59 Custom Types
13:34 Intersection Types
15:07 Function Type Annotation
17:19 Type Casting
19:51 Optional Function Parameters
21:53 Generics
28:28 Outro
Music used:
Parallel Synthesis by | e s c p | www.escp.space
Goodbye Ocean by | e s c p | www.escp.space
Happy scripting!

Пікірлер: 56

  • @miguelalexandre3203
    @miguelalexandre32032 ай бұрын

    man, your content its the best of roblox studio community, like you teach everything that's nobody teach in youtube, and for the beginners this content help so much

  • @haxking2
    @haxking22 ай бұрын

    I was literally learning this from devforum a few hours ago how can your timing be so perfect

  • @MichaelObamaSon
    @MichaelObamaSon2 ай бұрын

    thank you so much for listening to viewers! this video really helped me out with type annotations!! :D

  • @MichaelObamaSon

    @MichaelObamaSon

    2 ай бұрын

    also, thanks so much for chapters too, its a really nice touch

  • @epixerty
    @epixerty2 ай бұрын

    very interesting, i have around 2.5 years of experience but my code is a bit unprofessional, i never really use types for anything and this has taught me a lot of new things. this is the first time i see those "generic functions", it'll be hard to get used to this way of coding but i'll definitely try to apply this to make cleaner and more organised code, thank you for this amazing video!

  • @cryptic2742
    @cryptic27422 ай бұрын

    I adore how this man actually listens to his comments

  • @Alexandre94fr
    @Alexandre94fr2 ай бұрын

    Thank you very much for your video. 😄 Lua's dynamic typing has its advantages, however being able to define types for its functions, arguments, as well as variables is really important (for me) in order to have understandable, and predictable code.

  • @lua_programmer
    @lua_programmer2 ай бұрын

    This is an amazing tutorial right here!

  • @Kitsune_Dev
    @Kitsune_Dev2 ай бұрын

    I didn’t know how to use Literal types, Intersection, Type casting and Generics you improved my understanding of type annotations 👍🏻

  • @Tamla1959
    @Tamla19592 ай бұрын

    thanks for covering this!

  • @mrstarfish
    @mrstarfish2 ай бұрын

    Idk if you cover this, but I recently found out you can do: Local table = { State = “Idle”, Test = 5 } Type T = typeof(table) This was pretty useful for me with long tables that get passed around in functions. And for the state variable you can also do this: Type T = { State: “Idle” | “Combat” } & typeof(table) ^ uses table from previous example, and with the & symbol it will still auto fill the ‘Test’ variable.

  • @crusherfire1

    @crusherfire1

    2 ай бұрын

    Not covered in the video, but yes, you can use the typeof() function for creating types. In fact, you can pass virtually anything to it, including instances. Let's say you have some kind of standard-instance in your game you need to use for something and want the autofill capabilities for grabbing properties, children, and other stuff in that instance. Use the typeof() function on it and store the result in a new type and then you can use it anywhere!

  • @rocketcamel729
    @rocketcamel7292 ай бұрын

    Great video on type annotation! (I totally didn’t see your community post sorry!)see a lot of people asking about your font. Sorry to make you check, but for your roblox studio script editor theme do you use a plugin of some sort? And if so, can you provide the theme you use? I like it more than the default theme where the functions are yellow instead of orange for example. I've seen a theme called toasty that looks similar to yours. Cheers!

  • @ifthenelse2469
    @ifthenelse24692 ай бұрын

    I NEED THESE CUSTOM TYPES ON MY LIFE

  • @jam5936
    @jam59362 ай бұрын

    Needed this

  • @SinstixMain
    @SinstixMain2 ай бұрын

    Finally!!!

  • @KiloDev
    @KiloDev2 ай бұрын

    I really didn't know this, thank you! Hmph, I kind of wish there was a way to make studio error when you pass the wrong type using type annotation so that we don't have to add a check for the type. I know it shows a warning but studio doesn't error and the function will continue to execute.

  • @RoboGameOfficial
    @RoboGameOfficial2 ай бұрын

    You could also write intersection types like this: type a = { num: number } type b = a& { str: string } Also, I think you forgot to talk about being able to export types outside of a module script!

  • @crusherfire1

    @crusherfire1

    2 ай бұрын

    Yup, thanks for bringing that up! You can export types from a module script using the export keyword!

  • @Jamal.frl_13
    @Jamal.frl_132 ай бұрын

    Every thing I learn you make a tutorial about it 1 week later 😭

  • @mychannelnameisthis
    @mychannelnameisthis2 ай бұрын

    Wow, this is a great video and easy to understand, thank you so much. Also, by the way, how do you make "->" to be a arrow? What form is this? How is it possible to also have? Each line you create has a "->", could you tell me what's it? I'm looking for a styled script like that for a long time.

  • @crusherfire1

    @crusherfire1

    2 ай бұрын

    It's part of the font I'm using which is JetBrains Mono!

  • @notdaycrucial5179
    @notdaycrucial51792 ай бұрын

    do you think you could show us your code editor color palette?

  • @crusherfire1

    @crusherfire1

    2 ай бұрын

    Sure, I can post it on a community post soon

  • @embry4117

    @embry4117

    2 ай бұрын

    @@crusherfire1 please do, it looks soo clean

  • @workindad
    @workindad2 ай бұрын

    @Crusherfire I’m just not getting type inferencing when using on touch events. When I try to get the character and/or humanoid I just get red lines. Is this wrong way to use types?

  • @MrNobody-vb8rf
    @MrNobody-vb8rf22 күн бұрын

    quick question how do your change your font in scripts?

  • @VSurge
    @VSurge3 күн бұрын

    What is your color scheme for the scripts?

  • @SupposedlyChase
    @SupposedlyChase2 ай бұрын

    Can you go back to PRI

  • @AlteFore
    @AlteFore2 ай бұрын

    No views in 0 minutes? Bro fell off 😔

  • @crusherfire1

    @crusherfire1

    2 ай бұрын

    I've fallen and I can't get up!

  • @Developer_Max

    @Developer_Max

    2 ай бұрын

    ​@@crusherfire1 Should i call 911?

  • @crusherfire1

    @crusherfire1

    2 ай бұрын

    @@Developer_Max Call David Baszucki!

  • @Tamla1959
    @Tamla19592 ай бұрын

    hi i came back because i want to use multiple arguments for my function, but not sure how to declare them, like set them as a variable, using the dots like you did here: 17:10

  • @crusherfire1

    @crusherfire1

    2 ай бұрын

    You would want to store the unknown amount of arguments into a table so you can loop through them. Example: local args = {...}

  • @Tamla1959

    @Tamla1959

    2 ай бұрын

    @@crusherfire1 yes but how would you define them is what im saying, so like local args = {...} args.Argument1 = true args.Argument2 = "this is a string" that seems to me the most logical way of settings and defining the arguments, but it dosent work that way unfortunetly

  • @ilovecinnamonbuns
    @ilovecinnamonbuns2 ай бұрын

    what font do you use in the script editor?

  • @crusherfire1

    @crusherfire1

    2 ай бұрын

    JetBrains Mono!

  • @jesterlow
    @jesterlow2 ай бұрын

    didnt watch the whole vid but its kinda similar to typescript right

  • @Sand.
    @Sand.2 ай бұрын

    you make tutorials on more obscure parts of roblox luau, thanks so much!

  • @SlightlySchizophrenic
    @SlightlySchizophrenic2 ай бұрын

    feel like this is a stupid question but wtf is the difference between lua and luau

  • @crusherfire1

    @crusherfire1

    2 ай бұрын

    Luau is a scripting language derived from Lua 5.1

  • @m3s5_0f_numb3r5
    @m3s5_0f_numb3r52 ай бұрын

    I understand now, but…I don’t really…see what the point is? I dunno maybe it’s just the way I script but…I don’t really see the point in using type annotation. Maybe generic functions, but other than that I don’t exactly see how it could help me. Thanks for covering it anyway though! You never know when something like this might come in handy, so I’m not really complaining. 👍👍👍

  • @mychannelnameisthis

    @mychannelnameisthis

    2 ай бұрын

    The point of learning the type annotation in LuaU is just to make your scripting view more clear and faster for you, if you try using it, can benefit your time in scripting by alot when you're referring to a variable or anything like that.

  • @embry4117

    @embry4117

    2 ай бұрын

    I use it for tab completion sometimes such as passing player through a function. If I did player.Character it wouldnt autocomplete "Character" unless if I have func(player : Player)

  • @wclxb

    @wclxb

    2 ай бұрын

    it's extremely useful when working with more than one person. when using modules / modifying other scripts, seeing the expected types is one less thing you have to think about when reading a script written by someone else.

  • @d86i
    @d86i2 ай бұрын

    what is the coding font you use in scripting?

  • @crusherfire1

    @crusherfire1

    2 ай бұрын

    JetBrains Mono

  • @d86i

    @d86i

    2 ай бұрын

    @@crusherfire1 theres no font in studio called jetbrains mono

  • @d86i

    @d86i

    2 ай бұрын

    @@crusherfire1 nevermind thanks

  • @dunlng

    @dunlng

    2 ай бұрын

    how did you find it? I don't see a font called jetbrains mono@@d86i

  • @user-fi5hr2ig4s
    @user-fi5hr2ig4s2 ай бұрын

    mewo

  • @NORMAL_ACCOUNT...
    @NORMAL_ACCOUNT...2 ай бұрын

    what is the purpose of learning this

  • @crusherfire1

    @crusherfire1

    2 ай бұрын

    to be epic

  • @_beyi
    @_beyi2 ай бұрын

    luau is great :D lua has no type annotation :\

Келесі