Random - Roblox Beginners Scripting Tutorial #15 (2024)

Поделиться
HTML-код
  • Опубликовано: 27 дек 2024

Комментарии • 355

  • @Jundazz
    @Jundazz 4 месяца назад +43

    local pet = math.random(1, 5)
    if pet == 1 then
    print("You got a cat")
    elseif pet == 2 then
    print("you got dog")
    else
    print("you got unlucky and your pet didnt hatch")

    end
    simple pet opening

    • @MeowToonYT
      @MeowToonYT 26 дней назад +3

      Pet sim in a nutshell

    • @ZoneBlox
      @ZoneBlox 8 дней назад

      ​@@MeowToonYT--[[Wrong there is the code]]
      Local pet = math.random(1, 10)
      If pet = 9.7 then
      Print("you got below normal")
      If pet >=9.9 then
      Print ("you got normal")
      If pet >=9.99 then
      Print("you got mythical")
      If pet>= 9.99999 then
      Print("you got huge")

    • @janjaap58
      @janjaap58 6 дней назад

      I don't think that will work cuz it doesn't make decimal numbers.​@@ZoneBlox

  • @hechiv6085
    @hechiv6085 5 месяцев назад +49

    Woah woah, slow down with the upload speed fam. I'm still practicing the previous guide🗿(I appreciate the tutorials🙏. Also, you're really good at simplifying and explaining the concepts.)

  • @SkullsDev
    @SkullsDev 5 месяцев назад +111

    RNG games: WRITE THAT DOWN! WRITE THAT DOWN!

    • @TropialGamingYT
      @TropialGamingYT 4 месяца назад +1

      real

    • @atotallylazyperson
      @atotallylazyperson 4 месяца назад +8

      devs fr boutta
      local nochance = math.random(1, 1000000)
      if nochance == 1 then
      - - get really good aura script here
      end

    • @BlueTheCrew
      @BlueTheCrew 3 месяца назад +2

      @@atotallylazyperson really bad aura*

    • @atotallylazyperson
      @atotallylazyperson 3 месяца назад +4

      @@BlueTheCrew oh yeah mb

    • @SimplyTutuco
      @SimplyTutuco 2 месяца назад +1

      @@atotallylazyperson more like this:
      local defaultCommonChance = math.random(1,2)
      if defaultCommonChance == 69 then
      insert default aura creation script here
      end

  • @Mr.Pegumin
    @Mr.Pegumin 5 месяцев назад +15

    some of the best underatted script teaching channel man. keep up the good work!

  • @osakadev
    @osakadev 5 месяцев назад +29

    Summary (I was sleeping)
    math.random() is a function which generates pseudo-random numbers within the range of the first parameter and the second
    More data:
    - If you do not pass parameters, math.random() will generate numbers from 0 to 1
    - If the parameter a is greater than the parameter b, then an error will be thrown (and also if b is less than a)
    Examples of math.random()
    - Get a random element from a table:
    local numbers = {1, 2, 3, 4, 5, 6}
    print(numbers[math.random(1, #numbers)] -- print a random number inside the table!
    By the way, results of math.random() are going to depend on math.randomseed()

    • @reaklaz
      @reaklaz 5 месяцев назад +2

      is he feeding you? cuz i see you on every video

    • @osakadev
      @osakadev 5 месяцев назад +1

      @@reaklaz i'm his helper

    • @jvdeonyourblock
      @jvdeonyourblock 4 месяца назад +2

      @@osakadev what does the "pseudo" mean

    • @jvdeonyourblock
      @jvdeonyourblock 4 месяца назад +1

      also your comments are really helpful, thanks

    • @osakadev
      @osakadev 4 месяца назад +2

      @@jvdeonyourblock pseudorandom in this case, means "numbers NOT REALLY random", cuz computers cannot generate real random numbers

  • @AFMrPink
    @AFMrPink Месяц назад +6

    I used some of the code taught so far
    local function RNG()
    local randomNumber = math.random(1, 1000)
    if randomNumber 800 and randomNumber 900 and randomNumber 950 and randomNumber 975 and randomNumber 990 and randomNumber

    • @grainter5
      @grainter5 28 дней назад

      Here's a tip: every time your function loops, it'll be a few miliseconds off because of the way you wrote it. Don't ask me why, i don't know. But if you wanna fix it you can instead put all the code inside that function, inside the while true do loop. And here's another tip: don't put "task.wait(whatever number here)" inside a while true loop if you wanna wait until it loops again, instead just type "while task.wait(some number here) do" and it'll do the same.

  • @janjaap58
    @janjaap58 6 дней назад +2

    I tried to make 1 out of 3 blocks get a random color if you touch the Big part
    local P1 = game.Workspace.P1
    local P2 = game.Workspace.P2
    local P3 = game.Workspace.P3
    local P4 = game.Workspace.P4
    local SafetyFeature = false
    P1.Touched:Connect(function(GH)
    local touch = GH.Parent:FindFirstChild("Humanoid")
    if touch and SafetyFeature == false then
    SafetyFeature = true
    local N1 = math.random(1, 3)
    print(N1)
    local red = math.random(0, 255)
    local green = math.random(0, 255)
    local blue = math.random(0, 255)
    if N1 == 1 then
    P2.Color = Color3.fromRGB(red, green, blue)
    end
    if N1 == 2 then
    P3.Color = Color3.fromRGB(red, green, blue)
    end
    if N1 == 3 then
    P4.Color = Color3.fromRGB(red, green, blue)
    end
    wait(1)
    SafetyFeature = false
    end
    end)

  • @LavaWander
    @LavaWander 5 месяцев назад +15

    I used some of my GUI knowledge and made a button that rolls a die. This is the script I put inside it.
    local roll = script.Parent
    roll.MouseButton1Click:Connect(function()
    local result = roll.Parent:FindFirstChild("Result")
    local rolled = math.random(1, 6)

    if rolled == 1 then
    result.TextColor3 = Color3.fromRGB(255, 0, 0)
    elseif rolled == 6 then
    result.TextColor3 = Color3.fromRGB(0, 255, 0)
    else
    result.TextColor3 = Color3.fromRGB(0, 0, 255)
    end

    result.Text = "ROLLED: " .. rolled
    end)

    • @JustASimpleMan07
      @JustASimpleMan07 Месяц назад

      "MouseButton1Click" is not even a thing?

    • @LavaWander
      @LavaWander Месяц назад

      @JustASimpleMan07 It has minor differences to "Activated"

  • @z1ngetsuu
    @z1ngetsuu 2 месяца назад +3

    (speed orb that gives you 5 toalkspeed. and the orb is also randomly changing colors)
    local toggle = false
    script.Parent.Touched:connect(function(hit)
    local cooldown = (3)
    local duration = (10)
    local randomNumber = math.random(5, 20)
    local part = script.Parent
    if toggle == false then
    if hit.Parent:FindFirstChild("Humanoid") then
    toggle = true
    part.Transparency = 1
    part.CanTouch = false
    part.CanCollide = false
    hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed + randomNumber
    print(randomNumber)
    wait(cooldown)
    part.Transparency = 0.2
    part.CanTouch = true
    part.CanCollide = true
    toggle = false
    end
    end
    end)
    while true do
    local part = script.Parent
    local redValue = math.random(0, 255)
    local greenValue = math.random(0, 255)
    local blueValue = math.random(0, 255)
    part.Color = Color3.fromRGB(redValue, blueValue, greenValue)

    task.wait(0.2)
    end

  • @goofymctooty3650
    @goofymctooty3650 3 месяца назад +8

    Ive gone from nothing to learing how to give my friends a gambling addiction thanks man

  • @CloudKicks.official
    @CloudKicks.official 4 месяца назад +1

    thank you very much bro. i have watched more than 100 tutorials but yours hit different i understood everything. and everything worked even doin it by my self. i cant really tell you how much i appreciate. thank you!!!

  • @Sky_Blue_Crew
    @Sky_Blue_Crew 4 месяца назад +2

    This is an episode I've been waiting for, its perfect for my script random color script, so here is:
    --set variable
    local partTouched = false
    local RandomCounter = 1
    --random color loop
    script.Parent.Touched:Connect(function(part)

    if partTouched == false then
    local humanoid = part.Parent:FindFirstChild("Humanoid")
    if humanoid then
    partTouched = true
    while RandomCounter

  • @Titananderson
    @Titananderson 12 дней назад +1

    local function petGamble()
    while true do
    task.wait(1)
    local gambling = math.random(1, 20)
    if gambling == 1 then
    print("you got a dragon!")
    elseif gambling

  • @Strange_occurance
    @Strange_occurance Месяц назад +3

    these tutorials are really helpful

  • @cobyjacob2054
    @cobyjacob2054 4 месяца назад +5

    -- function that prints the name of a certain world type
    local function randomNumber()
    local ranNum = math.random(1, 4)
    if ranNum == 1 then
    print("Ice world")
    elseif ranNum == 2 then
    print("Desert")
    elseif ranNum == 3 then
    print("Pirate island")
    elseif ranNum == 4 then
    print("The vulcano")
    end
    end
    randomNumber()

    • @grainter5
      @grainter5 28 дней назад

      here's a tip: if you're only going to use a function once, you shouldn't use a function at all and instead just write the code inside the function itself.

    • @zuhniwnl
      @zuhniwnl 17 дней назад

      @@grainter5 huh

    • @grainter5
      @grainter5 16 дней назад

      @@zuhniwnl if youre gonna make a function but then only use it once, the function was pointless because you could've just written whatever code was in the function and it would've ran the same but with less lines

  • @JoeKSP
    @JoeKSP 14 часов назад +1

    local display = game.Workspace.sign.SurfaceGui.TextLabel
    timeLeft = math.random(20, 100)
    display.Text = timeLeft
    for countdown = 1, timeLeft, 1 do
    timeLeft = timeLeft - 1
    display.Text = timeLeft
    task.wait(1)
    end
    this does so a countdown starts on a textlabel, the number to countdown from is random but whatever it is it always stops at 0

  • @RubickO7
    @RubickO7 4 месяца назад +5

    local Rarity = math.random(1, 5)
    if Rarity == 1 then
    print("you got uncommon")

    elseif Rarity == 2 then
    print("common")
    elseif Rarity == 3 then
    print("rare")
    elseif Rarity == 4 then
    print("legendary")
    elseif Rarity == 5 then
    print("limited")
    end
    print(Rarity)

    • @KaYi25
      @KaYi25 3 месяца назад +8

      doesnt make sense to add rarities if all the values have the same chance of being chosen.

    • @retroAIO
      @retroAIO 2 месяца назад

      @@KaYi25fr

  • @PlayFroge_gamer
    @PlayFroge_gamer 22 дня назад +1

    why does this video have exactly 9 minutes and 11 seconds?
    btw here is what i did
    local plate = game.Workspace.Baseplate
    while true do
    plate.Color = Color3.new(math.random(0, 260), math.random(0, 260), math.random(0, 260))
    wait(3)

    end
    -- it is also a way to do it without any variable but if you want to use it for different objects etc it is better to use variables

  • @VoidBloomYT
    @VoidBloomYT 4 месяца назад +18

    heres a code that i made to signify my gambling addiction.
    while true do

    local random = math.random(1, 6)

    print(random)

    if random == 6 then

    print("jackpot!")

    end

    task.wait(2)
    end

  • @space.13311
    @space.13311 17 дней назад

    its crazy how it went from 50k + to 26k wow
    i love your tutorials it helped me

  • @MeowToonYT
    @MeowToonYT 26 дней назад +1

    An advice from me is to write down all the events you learned in a book or document

  • @xastrovibzx587
    @xastrovibzx587 Месяц назад +1

    --Imma fr make a rng thing really quick or try to anyways
    local Common = "Common"
    local Rare = "Rare"
    local Epic = "Epic"
    local Legendary = "Legendary"
    local Mythic = "Mythic"
    while true do
    local numbers = math.random(1, 6)
    if numbers == 1 then
    print("Rolled ", Common)
    elseif numbers == 2 then
    print("Rolled ", Rare)
    elseif numbers == 3 then
    print("Rolled ", Epic)
    elseif numbers == 4 then
    print("Rolled ", Legendary)
    elseif numbers == 5 then
    print("Rolled ", Mythic)
    elseif numbers == 6 then
    print("Spinning has ended for hitting 6.")
    break
    end
    task.wait(1)
    end
    --Kinda forgot to make Uncommon but that's alright lol. This should roll until you get 6 which will then stop spinning and print your rarity each time.

    • @Mango_-
      @Mango_- Месяц назад

      looks like a python script ngl

  • @Fudge_Minister
    @Fudge_Minister День назад +1

    I made an epilepsy block 😀

  • @amvyori5617
    @amvyori5617 Месяц назад

    new to scripting and have been trying to learn steadily so i made this:
    local randomNumber = math.random(1, 6)
    print(randomNumber)
    if randomNumber >= 1 and randomNumber = 4 and randomNumber

  • @vmc-mal
    @vmc-mal 5 месяцев назад +2

    Almost done with the playlist, have learnt quite a lot!
    local rng = math.random(1,64)
    local roof1 = game.Workspace.House.Roof1
    local roof2 = game.Workspace.House.Roof2
    --[[ Disabling this since I am using this script actively.
    print(rng)]]
    --This randomizes the color of the roof.
    while true do
    local rv = math.random(0,255)
    local gv = math.random(0,255)
    local bv = math.random(0,255)
    roof1.BrickColor = BrickColor.new(Color3.fromRGB(rv, gv, bv))
    roof2.BrickColor = BrickColor.new(Color3.fromRGB(rv, gv, bv))
    task.wait(.5)
    end

  • @RobloxClipShorts
    @RobloxClipShorts 2 месяца назад

    I can't believe I'm already here, thank you so much!

  • @imthesilly-k9j
    @imthesilly-k9j 2 месяца назад +1

    Yo, I have one question about this whole thing. I’m trying to make a game with my friend and you didn’t really explain one of the parts that I need to know so maybe can you explain it if you reply to this I’ll tell you what I need to explain.

  • @banditbaws
    @banditbaws Месяц назад

    I created a "gamba sphere" that spins for either a "common" or a "rare" using the math.random function when touched by a humanoid with a 1.5s cooldown
    local sphere = script.Parent
    local cooldown = false
    sphere.Touched:Connect(function(partTouched)
    local humanoid = partTouched.Parent:FindFirstChild('Humanoid')
    if humanoid then
    if cooldown == false then
    cooldown = true
    local randomValue = math.random(1,6)
    if randomValue = 5 then
    print('Rare')
    end
    task.wait(1.5)
    cooldown = false
    end
    end
    end)

  • @MdkerMdxer
    @MdkerMdxer 4 месяца назад

    6:35 u can also change the baseplate color using the following script
    local Baseplate = game.Workspace.Baseplate
    Baseplate.BrickColor = BrickColor.Random()

    • @SimplyTutuco
      @SimplyTutuco 2 месяца назад

      BrickColor.Random() limits the amount of colors, now the way he did is absolutelly any color out of the over 765 the game has.

  • @fascinatingfaux811
    @fascinatingfaux811 5 месяцев назад +2

    I was able to make some spheres that roll around a box and change colors every few seconds but I can’t paste the code since I’m not on the PC right now.

  • @elijah444
    @elijah444 2 месяца назад

    I made a button that has a 1/10 chance to turn a screen yellow! Amazing tutorials btw

  • @Romyplaysgames
    @Romyplaysgames Месяц назад

    local room = math.random(1, 3)
    if room == 1 then
    print("scary room")
    elseif room == 2 then
    print("nice room")
    elseif room == 3 then
    print("horrifying room")
    end

  • @TheCoolCat521
    @TheCoolCat521 Месяц назад +1

    An almost impossible (1/16581375) random guesser where there are 3 generator that fires once and 3 generator on a while loop. The (unrealistic) goal is to match the generated value of all 3 RGB color.
    local random1 = math.random(0, 255)
    local random2 = math.random(0, 255)
    local random3 = math.random(0, 255) -- generating the colors of the "answer"
    local part = game.Workspace.Part
    local Answer = print(random1, random2, random3) -- defining the "answer"
    while true do -- while loop
    task.wait(0.2)
    local randomR = math.random(0, 255)
    local randomG = math.random(0, 255)
    local randomB = math.random(0, 255) -- guessing the color value for the 3 color which will be checked

    if random1 == randomR and random2 == randomG and random3 == randomB then -- checks the answer
    print('Nice you got the correct color,', Answer)
    part.Color = Color3.fromRGB(randomR, randomG, randomB)
    else part.Color = Color3.fromRGB(randomR, randomG, randomB) -- continues if answer is wrong
    end
    end

  • @DevRRG
    @DevRRG 2 месяца назад +1

    Although i am not a beginner dev i watched this Video to learn more about math.random. i made a local script inside of starterplayerscripts, everytime a player pressed the letter F, the baseplate color changes randomly here is the script: local Uis = game:GetService("UserInputService")
    local baseplate = game.Workspace:WaitForChild("Baseplate")
    if baseplate then
    print("baseplate is in Workspace")
    else
    warn("baseplate is not in Workspace")
    end
    Uis.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.F then
    print("F has been Pressed")

    local redValue = math.random(0, 255)
    local greenValue = math.random(0, 255)
    local blueValue = math.random(0, 255)

    baseplate.Color = Color3.fromRGB(redValue, greenValue, blueValue)

    end
    end)

    • @6xysh
      @6xysh 2 месяца назад

      woahh

    • @TANER845
      @TANER845 2 месяца назад

      show off

    • @DevRRG
      @DevRRG 2 месяца назад

      @@TANER845 huh?

    • @purple-ispurple
      @purple-ispurple 2 месяца назад

      That actually made sense

    • @truongvinh3386
      @truongvinh3386 2 месяца назад +1

      ​@TANER845 it's not showing off this person is a intermediate-pro dev, by them kindly sending these codes newer devs like me can learn too. Maybe ur just jealous cause u suck but it's not showing off

  • @grainter5
    @grainter5 28 дней назад

    while task.wait(2.5) do
    local i = math.random(1,1000)
    if i >= 990 then
    print("Legendary")
    elseif i >= 900 then
    print("Epic")
    elseif i >= 750 then
    print("Rare")
    elseif i >= 500 then
    print("Uncommon")
    elseif i >= 2 then
    print("Common")
    else
    print("Mythical")
    end
    end
    -- very simple code that i wrote, runs every 2.5 seconds and will print one of those messages. some are much rarer than others and "Mythical" is 1/1000.

  • @Exrl_
    @Exrl_ 2 месяца назад

    nice video lenght

  • @ettoremoralles5633
    @ettoremoralles5633 Месяц назад

    I upgraded a bit the script of changing the basePlate color, i made it deect if a especific block is being touched by a player so it can run the script to change the baseplate color
    local changeb = game.Workspace:WaitForChild("Mudar") -- ensures that the part exist
    local debounce = false
    changeb.Touched:Connect(function(otherPart)
    if not debounce then
    debounce = true
    print("Touched by:", otherPart.Name)
    changeb.Color = Color3.new(0, 0, 0)
    local humanoid = otherPart.Parent:FindFirstChild("Humanoid") -- ensures that the body part exist
    if humanoid then
    local plate = game.Workspace:WaitForChild("dw") -- ensures that the baseplate exist
    local count = 1
    while count

  • @YorSato
    @YorSato 2 месяца назад +1

    3 more videos and i should be done with this and i can move to the advance one P.S this is my second day tomorow im gone watch the last 3 and i should be good to go GOOD NIGHT P.S your teaching skills are very good you should be a teach no cap

  • @MaximLankin
    @MaximLankin 4 месяца назад

    first time learning in depth i feel lowkey happy with this code i created a brick that randomizes color every time its touched with debounce that i had to search up how to do because i was frustrated that the colors kept changing as long as i touched the brick
    local brick = script.Parent
    local debounce = false
    brick.Touched:Connect(function(otherpart)
    local humanoid = otherpart.Parent:FindFirstChild("Humanoid")
    if humanoid and not debounce then
    debounce = true

    local redValue = math.random(0, 255)
    local greenValue = math.random(0, 255)
    local blueValue = math.random(0, 255)

    brick.Color = Color3.fromRGB(redValue, greenValue, blueValue)
    task.wait(1)
    debounce = false
    end
    end)

  • @rizzzzzlestudios5555
    @rizzzzzlestudios5555 2 месяца назад

    good video 👍👍

  • @JohnSminks
    @JohnSminks 5 месяцев назад +1

    local baseplate = game.Workspace.Baseplate
    while true do
    local randomValue = math.random()
    baseplate.Transparency = randomValue

    if baseplate.Transparency > 0.9 then
    print("Wow, your baseplate is pretty dang transparent.")
    end
    task.wait(1)
    end

  • @KJsjdjsjsj
    @KJsjdjsjsj 2 месяца назад

    Btw for the random baseplate color you dont have to do that just do this
    local baseplate = game.workspace.Baseplate
    local color = 1
    baseplate.Touched:connect(function(change)
    while color < 5 do
    baseplate.BrickColor = Brickcolor.random()
    task.wait(1)
    end
    end)

  • @somethingmysterious1135
    @somethingmysterious1135 19 дней назад

    Randomly changes the value of transparency(0.2-0.5):
    local brickFinder = script.Parent
    while true do
    brickFinder.Transparency = math.random(2, 5) / 10 -- Had a hard time getting floating point values but looked online to find out that u can divide by 10 to get floating points
    task.wait(1)

    end

  • @sora5484
    @sora5484 20 дней назад

    if the baseplate gets touched, it turns a random value of transparency:
    local baseplate = game.Workspace.Baseplate
    local humanoid = baseplate.Touched:Connect(function(otherPart)
    local touched = false
    if touched == false then
    touched = true
    local transparency = math.random()
    baseplate.Transparency = transparency
    print("It is invisibile now")
    task.wait(2)
    end

    end)

  • @shodisk
    @shodisk 3 месяца назад +3

    local money = 1782300
    local eggCost = 20000
    while money >= eggCost do
    local chance = math.random(1, 100)

    if chance

    • @akuji9166
      @akuji9166 3 месяца назад +1

      I wanna ask something the "if chance

    • @akuji9166
      @akuji9166 3 месяца назад

      elseif chance

  • @JailbreakerSlower
    @JailbreakerSlower 4 дня назад

    randomNumber = math.random(1, 10)
    print(randomNumber)
    if randomNumber

  • @liutenant-blob_pond
    @liutenant-blob_pond 2 месяца назад

    So i decided to model a discord setup, a simple 3x3. i would use what we learnt from last video(Script.Parent) to relate to the part, adding it into the parts. eventually the script worked with 1, so i copied it into the others not needing to chnage(cuase the parent is changing), and....
    IT WORKED.
    if you want to try this out for yyourself, or jus t wanna see the script, i used the same one from the video, here is the script:
    local color = script.Parent
    while true do
    local redValue = math.random(0,225)
    local blueValue = math.random(0,225)
    local greenValue = math.random(0,225)

    color.Color = Color3.fromRGB(redValue, blueValue, greenValue)
    task.wait(1)
    end

  • @thetruebigfloppa
    @thetruebigfloppa 13 дней назад

    this is pretty basic but i should definitely try anyways:
    local baseplate = workspace.Baseplate
    --[[while true do
    local redValue = math.random(0, 255)
    local greenValue = math.random(0, 255)
    local blueValue = math.random(0, 255)

    baseplate.Color = Color3.fromRGB(redValue, greenValue, blueValue)
    task.wait()
    end]]
    -- print("THIS IS COMPLETE CHAOS")
    --[[while true do
    baseplate.Transparency = math.random()
    task.wait()
    end]]
    while true do -- creates an infinite while loop
    local randomDecimal = math.random() --[[ creates a variable called randomDecimal and sets it to any number
    from 0 to 1]]
    local randomNumber = math.random(0, 1) -- creates a variable called randomNumber and sets it to either 0 or 1
    if randomNumber == randomDecimal then -- checks if randomNumber and randomDecimal are the same number
    print("THE STARS HAVE ALIGNED")
    end
    task.wait()
    end

  • @babyjacob_7855
    @babyjacob_7855 5 месяцев назад

    i also love this local dice = math.random(1, 6)
    local d = math.random(1, 6)
    print("And The Dice Roll Is... ".. dice + d)

  • @Soyzs
    @Soyzs Месяц назад

    Decided to do a really basic script where i just added onto the script made in video, it changes the baseplate color along with its transparency to from a value of (0, 1): local baseplate = game.Workspace.Baseplate
    while true do
    local redValue = math.random(0, 255)
    local greenValue = math.random(0, 255)
    local blueValue = math.random(0, 255)

    baseplate.Color = Color3.fromRGB(redValue, greenValue, blueValue)
    baseplate.Transparency = math.random(0.1, 1)

    task.wait(2)
    end

  • @Magnificent_Potato
    @Magnificent_Potato 6 дней назад

    I was honestly surprised that my code worked, but anyway here it is!
    local baseplate = game.Workspace.Baseplate
    while true do
    local redValue = math.random(0, 255)
    local blueValue = math.random(0, 255)
    local greenValue = math.random(0, 255)

    baseplate.Color = Color3.fromRGB(redValue, blueValue, greenValue)

    task.wait(1)

    if baseplate.Color == Color3.fromRGB(redValue, blueValue, greenValue) then
    print("The color has changed to a random color!")
    end
    end
    Thank you so much for teaching me to code BrawlDev!

  • @iCreateGamez
    @iCreateGamez 3 месяца назад

    I wanted to do something a bit more complex but it didn't work, and didn't stop using a particular number. And one time, it even crashed my game. This is the one I ended up with:
    local petOpening = math.random(1,5)
    if petOpening == 1 then
    print("You got a(n) [COMMON] Elephant (1/5)")
    end
    if petOpening == 2 then
    print("You got a(n) [COMMON] Dog (2/5)")
    end
    if petOpening == 3 then
    print("You got a(n) [UNCOMMON] ZEBRA (3/5)")
    end
    if petOpening == 4 then
    print("You got a(n) [LEGENDARY] DRAGON(4/5)")
    end
    if petOpening == 5 then
    print("You got a(n) [MYTHICAL] AZUNE(5/5)")
    end

  • @jakgutn
    @jakgutn 5 месяцев назад +1

    (as always) great tutorial🎉, but how can I do this if I want a decimal number with a certain number of decimal places? (for example two)

  • @sidecoolguy2858
    @sidecoolguy2858 25 дней назад +1

    local part = script.Parent
    local function pick()
    local pet = math.random(1,5)
    if pet == 1 then
    print ('you got dog')
    elseif pet == 2 then
    print ('you got cat')
    elseif pet == 3 then
    print ('you got mouse')
    elseif pet ==4 then
    print ('you got fox')
    elseif pet == 5 then
    print ('you got hamster')
    end
    end
    pick()

  • @reverdinm
    @reverdinm Месяц назад

    local baseplate = game.Workspace.Baseplate
    while true do
    local red = math.random(100, 255)
    local green = math.random(100, 255)
    local blue = math.random(100, 255)

    if red+green+blue >=580 then
    local result = math.random(1,3)
    if result == 1 then
    red = red - 120
    end
    if result == 2 then
    green = green - 120
    end
    if result == 3 then
    blue = blue - 120
    end
    end
    baseplate.Color = Color3.fromRGB(red, green, blue)
    wait(0.1)
    end
    I basically made a script that, when it is run, changes the baseplate's color 10 times every second. You know, like a disco. But I didn't want the weird blacks, browns, or other dark colors showing up (Like you'd normally see with math.random(0,255)) so I decided to make the minimum range higher - but then I found too much white or pastel colors showing up, so I also made it so that if the sum of all of their RGB values were too high, then I'd randomly pick one to subtract from, making yellow, purple and cyan more common. This results in a pretty decent disco floor.

  • @unianid7875
    @unianid7875 26 дней назад

    local randomNumber = math.random(1,2)
    if randomNumber == 1 then
    print("wow")
    elseif randomNumber == 2 then
    print("oh")
    end

  • @that-original-channel
    @that-original-channel 3 месяца назад

    local rand = math.random(1, 32)
    local jackpot = 32
    while true do
    if rand == jackpot then
    print("YOU HIT THE JACKPOT!")
    end
    task.wait(0.5)
    rand = math.random(1, 32)
    end

  • @EEAASSEE
    @EEAASSEE Месяц назад

    i did the baseplate thing but when it changes, the decal changes transparency (lazy)
    local baseplate = game.Workspace.Baseplate
    while true do
    local redvalue = math.random(0, 255)
    local greenvalue = math.random(0, 255)
    local bluevalue = math.random(0, 255)
    baseplate.BrickColor = BrickColor.new("white")
    baseplate.Texture.Transparency = 1
    task.wait(0.1)
    baseplate.Texture.Transparency = 0.50
    baseplate.Color = Color3.fromRGB(redvalue, greenvalue, bluevalue)
    task.wait(0.09)
    end

  • @Stickmangold360
    @Stickmangold360 3 месяца назад

    i made gambling script in the gui
    local text = script.Parent
    text.Visible = false
    while true do
    local roll = math.random(1,6)
    print(roll)
    if roll == 6 then
    text.Visible = true
    end

    task.wait(2)

    text.Visible = false
    end

  • @zenknight4839
    @zenknight4839 4 месяца назад

    while true do
    local ranWord = math.random(0, 3)

    if ranWord == 0 then
    print("Stepanci")
    elseif ranWord == 1 then
    print("Caporetto")
    elseif ranWord == 2 then
    print("Somme")
    else
    print("Aisne")
    end

    task.wait(3)
    end
    Basically a map randomizer

  • @scratchystuff
    @scratchystuff 8 часов назад

    te amount of people that hasn't come this far makes you have 906 likes

  • @Ecaw
    @Ecaw 4 месяца назад +1

    I don't really understand this one. I tried making it change transparency along with the color, but it wouldn't change the transparency. Anyone mind helping and giving an explanation along wiith it? Thank you.
    local randomTransparencyPart = game.Workspace.RandomPart
    while true do
    local transValue = math.random(0, 1)

    randomTransparencyPart.Transparency = transValue
    task.wait(2)
    end

    • @utmdreams
      @utmdreams 4 месяца назад

      I don't know much but i think that if there are 2 loops, the script goes through only one at a time and since while true do runs indefinitely, the script wont look for the transparency script

    • @ansjsj3ensudka
      @ansjsj3ensudka 4 месяца назад

      math.random() generates a number between 0 and 1by default so you can just do math.random()

    • @SimplyTutuco
      @SimplyTutuco 2 месяца назад

      You have to each loop in a separate script, since we didn't learn yet how to simultaneously run 2 loops in the same script yet.

  • @TropialGamingYT
    @TropialGamingYT 4 месяца назад

    The Root to Gambling Love it. Great video learned how to make a chance system and gamble...

  • @ChipiChipiKAYRA
    @ChipiChipiKAYRA 3 месяца назад

    I did a script that picks a number between 1 and 8 and a text shows that number
    local RandomNumber = math.random(1, 8)
    local Text = game.Workspace.RandomNumberPart.SurfaceGui.TextLabel
    Text.Text = (RandomNumber)

  • @goodnoob857
    @goodnoob857 4 месяца назад

    best ever scriping tutorial I have seen

  • @kruczak7896
    @kruczak7896 5 месяцев назад

    This dice can only be rolled once
    local cube = script.Parent
    local randomRoll = math.random(1, 6)
    cube.Touched:Once(function(SnakeEyes)
    local RFoot = SnakeEyes.Parent:FindFirstChild("RightFoot")
    if RFoot then
    print(randomRoll)
    end
    end)

  • @MACKENZIE_DAVID2
    @MACKENZIE_DAVID2 Месяц назад

    Thank you so much! I made a RNG button!

  • @TwinkleSav
    @TwinkleSav 3 часа назад

    here's what I made!
    local baseplate = game.Workspace.Baseplate
    while true do
    local randomValue = math.random(0.00, 1.00)

    baseplate.Transparency = randomValue
    task.wait(0.01)
    end

  • @imgonnatalk
    @imgonnatalk 5 дней назад

    local baseplate = game.Workspace.Baseplate
    local touchpart = game.Workspace.touchpart
    local partIsTouched = false
    touchpart.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    local red = math.random(0, 255)
    local green = math.random(0, 255)
    local blue = math.random(0, 255)
    partIsTouched = true
    print("part touched")
    baseplate.Color = Color3.fromRGB(red, green, blue)
    partIsTouched = false
    end
    end)
    every time you touch the touchpart that we made earlier the baseplate changes colors

  • @bigmacyummy8974
    @bigmacyummy8974 Месяц назад

    so basically i made a part that combines the events, find first child & wait for child and this tutorials for my script. The part changes the transparency and colors randomly when its touch with a 2 second cooldown!
    script:
    local colorPart = script.Parent
    local debounce = false
    colorPart.Touched:Connect(function(otherPart)
    if not debounce then
    local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
    if humanoid then
    debounce = true
    local redValue = math.random(0, 255)
    local greenValue = math.random(0, 255)
    local blueValue = math.random(0, 255)
    colorPart.Color = Color3.fromRGB(redValue, greenValue, blueValue)
    local randomTransparency = math.random()
    colorPart.Transparency = randomTransparency
    task.wait(2)
    debounce = false
    end
    end
    end)

  • @frbestguy
    @frbestguy 4 месяца назад +1

    local baseplate = workspace:FindFirstChild("Baseplate")
    local function randomNum()
    local randomnumber = math.random(1, 4)
    if randomnumber == 1 then
    baseplate.Color = Color3.fromRGB(255, 90, 100)
    elseif randomnumber == 2 then
    baseplate.Color = Color3.fromRGB(100, 255, 100)
    elseif randomnumber == 3 then
    baseplate.Color = Color3.fromRGB(100, 100, 255)
    elseif randomnumber == 4 then
    baseplate.Color = Color3.fromRGB(255, 255, 100)

    end

    end
    local counter = 1
    while counter

  • @DNLGio_de_Pio
    @DNLGio_de_Pio 23 дня назад

    local baseplate = workspace.Baseplate
    local randomNumber = math.random(1, 3)
    if randomNumber == 1 then
    baseplate.Transparency = 1
    baseplate.Anchored = false
    print("NOOOO!!! Don't die!")
    end
    print(randomNumber)

  • @aapple7993
    @aapple7993 5 месяцев назад

    --once brick touched, takes random amount of health, when touched again takes away from 0 - current health, part is rainbow
    local killBrick = script.Parent
    killBrick.Touched:Connect(function(otherPart)
    local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
    if humanoid then
    humanoid.Health = math.random(0, humanoid.Health)
    print('You now have', humanoid.Health)
    task.wait(1)
    end
    end)
    while true do
    local redValue = math.random(0, 255)
    local greenValue = math.random(0, 255)
    local blueValue = math.random(0, 255)
    killBrick.Color = Color3.fromRGB(redValue, greenValue, blueValue)
    task.wait(1)
    end

  • @chalmcal
    @chalmcal 5 месяцев назад +1

    (warning, big code)
    chamber = math.random(1, 6)
    if chamber == 1 then
    print("you are dead")
    else print("you lived")
    print(chamber)
    task.wait(2)
    chamber = math.random(1,5)
    if chamber == 1 then
    print("you are dead")
    else print("you lived")
    print(chamber)
    task.wait(2)
    chamber = math.random(1,4)
    if chamber == 1 then
    print("you are dead")
    else print("you lived")
    print(chamber)
    task.wait(2)
    chamber = math.random(1,3)
    if chamber == 1 then
    print("you are dead")
    else print("you lived")
    print(chamber)
    task.wait(2)
    chamber = math.random(1,2)
    if chamber == math.random(1,2) then
    print("you are dead")
    else print("you have lived")
    print(chamber)

    end
    end
    end
    end
    end

    • @chalmcal
      @chalmcal 5 месяцев назад

      I wasn't happy with that version so I improved it
      local gun = math.random(1, 6)
      local TheGame = script.Parent
      local fire = TheGame:FindFirstChild("fire")
      local spin = TheGame:FindFirstChild("spin")
      fire.Touched:Connect(function(otherpart)
      local humanoid = otherpart.Parent:FindFirstChild("Humanoid")
      if humanoid then
      if gun == 1 then
      humanoid.Health = 0
      print("you died")
      else print("you lived")
      gun = gun - 1
      task.wait(5)
      end
      else task.wait(5)
      end
      end)
      spin.Touched:Connect(function(otherpart)
      local humanoid = otherpart.Parent:FindFirstChild("Humanoid")
      if humanoid then
      gun = math.random(1, 6)
      print("coward")
      task.wait(5)
      end
      end)

    • @TheOnlyChunti
      @TheOnlyChunti 5 месяцев назад

      and how is it useful?

  • @ax4842
    @ax4842 3 месяца назад

    i did a luckyblock
    local touchPart = game.Workspace["LuckyBlock"]
    local partIsTouched = false
    touchPart.Touched:Connect(function(otherPart)
    local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
    if partIsTouched == false then
    partIsTouched = true
    local result = math.random(1, 20)
    if result

  • @Jouniii
    @Jouniii 26 дней назад

    Random colors on part when touched:
    local part = script.Parent
    part.Touched:Connect(function(touched)
    local humanoid = touched.Parent:FindFirstChild("Humanoid")
    if humanoid then
    local red = math.random(0, 255)
    local green = math.random(0, 255)
    local blue = math.random(0, 255)
    part.Color = Color3.fromRGB(red, green, blue)
    end
    end)

  • @slaveigaming
    @slaveigaming День назад

    i made that someblock simulate what i have got a common or a rare or a godly js like mm2 ur the best

  • @kiten9
    @kiten9 Месяц назад

    cant you just use random variable instead of 3 since they do they exact same thing 7:50

  • @Mah_guy
    @Mah_guy 5 месяцев назад

    this is a little rng game that i made!
    print("try to get 5 in the least tries possible!")
    local result = 0
    variable2 = 0
    function function1()
    variable2 = variable2 + 1
    result = math.random(1,5)
    print(result)
    if result == 5 then variable3 = 1
    else variable3 = 0
    end
    if variable3 == 1 then print("lucky duck!") print(variable2, "tries!")
    else print("try again!") function1()
    end

    end
    if result == 0 then function1()
    end

  • @MM-rl5xl
    @MM-rl5xl Месяц назад

    this is what i did to changes colors and speed to make it random
    local speedBrick = game.Workspace.TouchedPart
    while true do
    wait(math.random(.5, 1))

    red = math.random(0, 255)
    blue = math.random(0, 255)
    green = math.random(0, 255)

    speedBrick.Color = Color3.fromRGB(red, blue, green)

    if speedBrick then
    speedBrick.Touched:Connect(function(otherPart)
    local humanoid = otherPart.Parent:FindFirstChild("Humanoid")

    if humanoid then
    humanoid.WalkSpeed = math.random(1, 100)--You can change the speed from here (1, 100)
    end
    end)
    end
    end

  • @NicholasKiruthi
    @NicholasKiruthi 26 дней назад

    local function ranum()
    ranum = math.random(0,78)
    for ranum = 1, 100 do
    if ranum == 72 then
    print("I think we are done here!")
    break
    else
    continue
    end
    end
    end
    ranum()

  • @SLick31
    @SLick31 7 дней назад

    local shinypokemon = math.random(1, 5)
    if shinypokemon == 5 then
    print("Shiny Pokemon has appeared!")
    else
    print(shinypokemon)
    end

  • @RuthlesLatrell
    @RuthlesLatrell Месяц назад

    I made it loop
    local value = math.random(1,10)
    for theluckyloop = 1, 3, 1 do
    print("If this 10 sided dice lands on") task.wait(2) print(value) task.wait(2) print("you win a million dollars")
    task.wait(2)
    print("Rolling 10 sided dice...")
    local luckydraw = math.random(1,10)
    task.wait(2)
    if luckydraw == value
    then print("You win a million dollars you rolled a") task.wait(1) print(luckydraw)
    else print("Try again next time", "you rolled a") task.wait(1) print(luckydraw)
    task.wait(2)
    end
    end

  • @creepercraft2853
    @creepercraft2853 25 дней назад

    local wall = game.Workspace["The Wall"]
    while true do
    local transparency = math.random()

    wall.Transparency = transparency

    task.wait(0.5)
    end

  • @rodneysot
    @rodneysot 4 месяца назад

    local corner = script.Parent
    local Random = math.random(1, 12)
    corner.Touched:Connect(function(theOtherPart)
    local humanoid = theOtherPart.Parent:FindFirstChild("Humanoid")
    if humanoid then
    print (Random)
    end
    end)

  • @RaptorClaus0_0690
    @RaptorClaus0_0690 3 месяца назад +1

    "a six-sided die and when we roll this die its going to land on a number between 1 and 6"
    OH REALLY

  • @Sphereheadbozo
    @Sphereheadbozo 21 день назад

    while true do
    task.wait(1)
    local SolsRng = math.random(1,100)
    if SolsRng < 50 then
    task.wait(1)
    print("Common")
    elseif SolsRng > 50 and SolsRng < 80 then
    print("Uncommon")
    task.wait(1)
    elseif SolsRng > 80 and SolsRng < 95 then
    print("Rare")
    task.wait(1)
    else
    print("Legendary")
    break
    end
    end

  • @WildPlanetShorts1
    @WildPlanetShorts1 2 месяца назад

    ( took a 3 day break am rusty) mine -
    local pet = math.random(1,5)
    if pet == 1 then
    print("you have hatched a common dog!")


    elseif pet == 2 then
    print ("you have hatched a uncommon cat!")
    elseif pet == 3 then
    print("You have hatced a LEGENDARY FOX")
    elseif pet == 4 then
    print("you have hatched a RARE bunny!")
    elseif pet == 5 then
    print("GLOBAL PLAYER HAS HATCHED A SECRET DRAGON!")
    end
    print(pet)

  • @RealKyklops
    @RealKyklops 4 месяца назад

    Does anyone know what's wrong with my code? I tried to make a killbrick that only kills you if upon touching it, its red value is higher than the other values.
    However, as soon as the red value is higher than the other values even once, it'll continuously kill you upon touching it, even if later on the brick is completely blue.
    local model = script.Parent
    local part1 = model:FindFirstChild("Part1")
    while true do
    wait(2)
    local redValue = math.random(0, 255)
    local greenValue = math.random(0, 255)
    local blueValue = math.random(0, 255)
    part1.Color = Color3.fromRGB(redValue, greenValue, blueValue)
    part1.Touched:Connect(function(otherPart)
    local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
    if redValue >= greenValue and redValue >= blueValue and humanoid then
    humanoid.Health = 0
    else
    print("The redValue was lower, you're safe.")
    end
    end)
    end

  • @MyUsersCool
    @MyUsersCool 2 месяца назад

    I made a part when clicked, it sets the walk speed to a random number
    local speedrandomizer = game.Workspace.SpeedRandomizer
    local clickdetector = game.Workspace.SpeedRandomizer.ClickDetector
    clickdetector.MouseClick:Connect(function(player)
    local humanoid = player.Character:FindFirstChild("Humanoid")
    if humanoid then
    local numberforspeed = math.random(20, 200)
    humanoid.WalkSpeed = numberforspeed
    print("The Player Has A Speed Of:", numberforspeed)
    end
    end)

  • @Ggwinziscool
    @Ggwinziscool 4 месяца назад

    i made a RNG using prints, is there any way i can make this shorter?
    local RNG = math.random(1, 16)
    print(RNG)
    if RNG == 1 then
    print("you got a common")
    end
    if RNG == 2 then
    print("you got an uncommon")
    end
    if RNG == 3 then
    print("you got a rare")
    end
    if RNG == 4 then
    print("you got an epic")
    end
    if RNG == 5 then
    print("you got a legendary!")
    end
    if RNG == 6 then
    print("you got a mythic!")
    end
    if RNG == 7 then
    print("you got a destroyer!")
    end
    if RNG == 8 then
    print("you got a crazy!!!")
    end
    if RNG == 9 then
    print("YOU GOT ERROR!")
    end
    if RNG == 10 then
    print("you got a black hole!!?!?!")
    end
    if RNG == 11 then
    print("you got a nebula!")
    end
    if RNG == 12 then
    print("you got a DEATH!")
    end
    if RNG == 13 then
    print("you got a heaven!")
    end
    if RNG == 14 then
    print("you got a SUN!")
    end
    if RNG == 15 then
    print("you got a BREAKAGE!")
    end
    if RNG == 16 then
    print("you got a mentally unstable lol")
    end

    • @ansjsj3ensudka
      @ansjsj3ensudka 4 месяца назад +1

      local messages = {
      [1] = "you got a common",
      [2] = "you got an uncommon",
      [3] = "you got a rare",
      [4] = "you got an epic",
      [5] = "you got a legendary!",
      [6] = "you got a mythic!",
      [7] = "you got a destroyer!",
      [8] = "you got a crazy!!!",
      [9] = "YOU GOT ERROR!",
      [10] = "you got a black hole!!?!?!",
      [11] = "you got a nebula!",
      [12] = "you got a DEATH!",
      [13] = "you got a heaven!",
      [14] = "you got a SUN!",
      [15] = "you got a BREAKAGE!",
      [16] = "you got a mentally unstable lol"
      }
      local RNG = math.random(1, 16)
      print(RNG)
      print(messages[RNG])

  • @stenkkujontunen29
    @stenkkujontunen29 3 месяца назад

    You have helped me soo much with coding i really appriciate it and this is what i made.
    --[[
    local KillBrick = script.Parent
    KillBrick.Anchored = true
    KillBrick.Material = ("Neon")
    KillBrick.Color = Color3.fromRGB(255, 255, 255)
    local Thingy = true
    KillBrick.Touched:Connect(function(Otherpart)
    local Humanoid = Otherpart.Parent:FindFirstChild("Humanoid")
    Thingy = false
    local Sigma = math.random(0, 100)
    print(Sigma)
    if Humanoid then
    Humanoid.Health = (Sigma)
    while Thingy == false do
    local Greenvalue = math.random(0, 255)
    local BlueValue = math.random(0, 255)
    local RedValue = math.random(0, 255)
    if Humanoid then
    KillBrick.Color = Color3.fromRGB(Greenvalue,BlueValue,RedValue)
    task.wait(2)
    Thingy = true
    if Thingy == true then
    KillBrick.Color = Color3.fromRGB(255, 255, 255)
    end
    end
    end
    end
    end)
    ]]

  • @Sehaj_8ck
    @Sehaj_8ck 4 месяца назад +1

    Why this video is 9:11 long😅

  • @doge4101
    @doge4101 Месяц назад

    I have a tip for you guys, when doing math.random just use interval notation

  • @jakobmanton6889
    @jakobmanton6889 2 месяца назад

    Made a script to change the material on a big sphere
    local sphere = script.Parent
    while true do
    local randomNumber = math.random(1,3)
    if randomNumber == 3 then
    sphere.Material = "Plastic"
    elseif randomNumber == 2 then
    sphere.Material = "Metal"
    else
    sphere.Material = "Wood"
    end
    task.wait(5)
    end

  • @cubingmaster666
    @cubingmaster666 2 месяца назад

    local function randomNum()
    local randomNumber = math.random(0,1000000)
    print(randomNumber)
    end
    for printedNum = 1, 100, 1 do
    randomNum()
    if randomNum() ~= 100000 or 200000 or 300000 or 400000 or 500000 then
    print("Not good enough.")
    end
    end
    try to get a 1 in 200,000 :)

  • @Kirmizi_Domates
    @Kirmizi_Domates 4 месяца назад

    i did something like this for learning objective
    local part = script.Parent
    local colorChange = false
    local coolDown = false
    part.Touched:Connect(function(touched)

    local isHumanoidTouched = touched.Parent:FindFirstChild("Humanoid")

    if isHumanoidTouched and coolDown == false then

    colorChange = true

    if colorChange == true then
    local redRGB = math.random(0,255)
    local greenRGB = math.random(0,255)
    local blueRGB = math.random(0,255)
    part.Color = Color3.fromRGB(redRGB,greenRGB,blueRGB)
    colorChange = false
    coolDown = true
    task.wait(3)
    coolDown = false

    end



    end


    end)

  • @Snow-mw5jm
    @Snow-mw5jm 4 месяца назад

    local stud = script.Parent
    while task.wait(1) do
    scaryRNG = math.random(0,1)
    stud.Transparency = scaryRNG
    end

  • @Wriftx
    @Wriftx 15 дней назад +1

    Pet RNG system that works by the Humanoid touching a part.
    local function RNG ()
    local randomnumber = math.random (1, 1000)
    if randomnumber = 800 and randomnumber = 850 and randomnumber < 900 then
    print('Rare')
    elseif randomnumber >= 900 and randomnumber = 950 and randomnumber = 999 and randomnumber == 1000 then
    print('Insane You FUCKING LEGEND')




    end
    end
    local part = game.Workspace["Part"]
    part.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
    RNG ()
    end
    end)

  • @Thekingofbees12
    @Thekingofbees12 2 месяца назад

    Who else got 2 first try when testing random?