Going over 'Lua-Beginning-Lab' Challenges ~ Level One Projects Guide.


  • There was a game that I played on ROBLOX a few months ago that I thought we could look back at. I'm not sure on the original creator of the game because now there are many copies of the game floating around. The one I played can be found here.

    The game starts with the ability to read and answer many question. While that's not what I'll be going over, it is pretty fun and if you can beat my score, which was 388, let me know. I think the highest score you can get is 400.
    alt text

    Before reading the rest of these, feel free to try these challenges yourself.


    Challenge One:
    The first few challenges are rather simple. This one is to create a fading ball.
    alt text

    My script did manage to get under 16 lines. I tried doing it in a single for loop, but because I'm not very good at math, I sadly had to give up that idea.
    alt text

    I also did a division trick to get around floating point errors.

    Edit:
    I did manage to do the single for loop using math.abs, which is a simple function that returns the absolute value of a number. So, for example, math.abs(-50) is just 50.

    alt text

    Edit 2:
    There are even smaller solutions, but this uses more math so is technically more intensive on the computer, but not by much.

    alt text

    Challenge Two:
    alt text

    This one was also simple.
    alt text


    Challenge Three:
    alt text

    This one says check for humanoid, but it only wants it to kill players? I didn't check for humanoid, and instead only killed players.
    alt text


    Challenge Four:
    alt text

    I was a bit torn on this one. I was thinking about using a BodyGyro so that you moved with the part, but I went with the easy solution.
    alt text

    I think that's good enough.


    Challenge Five:
    alt text

    My solution used the random brick color function, and the .Color property of BrickColors.
    alt text


    Challenge Six:
    alt text

    This is a bit boring because I couldn't much think of anything to make this cool. I did decide to use a Humanoid instead of a SurfaceGui or something because it's easier.
    alt text


    Challenge Seven:
    alt text

    This one is actual something I see a lot of people struggle with. My solutions does follow the rules. I used a generic for loop to loop through all parts in the model. If there were multiple models in the one model, I would have used recursion. But I just went bare-bones and assumed there were only parts in the model. Because my script was also inside the model, I used IsA to make sure I had a part inside the loop.
    alt text


    That's the end of Level One! I'm excited to do Level Two! Thanks for reading, and I hope I inspire you to take on more challenges!

    Here's a link to the place with all my examples if you're stuck or want to see my solutions more closely.

    I you're ready, you can read part two of this tutorial here.


  • Challenge 1:-

    local ball = game.Workspace.Part
    local inc = 1
    while true do
    	for i=ball.Transparency * 100, 100 - ball.Transparency*100,  inc do
    		ball.Transparency = i/100
    		wait()
    	end
    	inc = inc * -1
    end
    

    :3


  • @kingdom5 Oh, that's smart. I was thinking of a different method in my head, but that works.

    Why not do inc = -inc instead of multiplying it by -1? :P


  • @kingdom5 This is what I was thinking. I managed to get it to work. I did it my first try this time. I must have been tired when I was writing this.
    alt text


  • @OldPalHappy idk which is faster but I usually use *-1, might test this :P

    alt text
    Its best to do the math once, this requires it to be calculated each loop XD

Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.