@@atotallylazyperson more like this: local defaultCommonChance = math.random(1,2) if defaultCommonChance == 69 then insert default aura creation script here end
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.)
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")
@@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")
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()
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
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.
(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)
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!!!
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
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
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)
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
-- 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()
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 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
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
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
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.
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
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
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.
6:35 u can also change the baseplate color using the following script local Baseplate = game.Workspace.Baseplate Baseplate.BrickColor = BrickColor.Random()
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
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)
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
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
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
--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.
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)
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!
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
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
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)
@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
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)
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)
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
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
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)
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)
(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)
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)
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)
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
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
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
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()
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
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
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.
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) ]]
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
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
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)
Lol, I made that whenever I touch the TouchPart, then teleportPart is going to teleport to the random location based on random numbers, I'm so proud. local touchPart = script.Parent local teleportedPart = touchPart:FindFirstChild("TeleportPart") local canTouchPart = true local function randomPosGen() local xPos = math.random(1, 30) local yPos = math.random(1, 5) local zPos = math.random(1, 30)
return Vector3.new(xPos, yPos, zPos) end local function tpPartOnTouch(otherpart) if teleportedPart and canTouchPart == true then local randomPos = randomPosGen() teleportedPart.Position = randomPosGen() canTouchPart = false task.wait(2) canTouchPart = true end end touchPart.Touched:Connect(tpPartOnTouch)
-- LEARNING OBJECTIVE: local function roll() local randomNumber = math.random(0, 1000)
if randomNumber >= 0 and randomNumber < 700 then print("COMMON!") elseif randomNumber >= 700 and randomNumber < 900 then print("RARE!!") elseif randomNumber >= 900 and randomNumber
took a little minute to figure out but this has the block randomly move local brick = game.Workspace.brick while true do local xValue = math.random(-1, 1) local yValue = math.random(-1, 1) local zValue = math.random(-1, 1)
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)
--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
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)
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.
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()
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
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
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)
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)
I made a slots machine, if you get any 3 numbers together you will get a small prize, and if all 3 numbers are 7's then you will get a jack pot. a single 10 will grant you a free spin and non matching numbers will respond with bad luck local value1 = math.random(1, 10) local value2 = math.random(1, 10) local value3 = math.random(1, 10) if true then print(value1, value2, value3) end if value1 == 7 and value2 == 7 and value3 == 7 then print("Jackpot!") elseif value1 == value2 and value2 == value3 then print("You got a small prize!") elseif value1 == 10 or value2 == 10 or value3 == 10 then print("You got a free spin!") else print("Bad luck!") end
RNG games: WRITE THAT DOWN! WRITE THAT DOWN!
real
devs fr boutta
local nochance = math.random(1, 1000000)
if nochance == 1 then
- - get really good aura script here
end
@@atotallylazyperson really bad aura*
@@BlueTheCrew oh yeah mb
@@atotallylazyperson more like this:
local defaultCommonChance = math.random(1,2)
if defaultCommonChance == 69 then
insert default aura creation script here
end
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.)
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
Pet sim in a nutshell
@@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")
I don't think that will work cuz it doesn't make decimal numbers.@@ZoneBlox
some of the best underatted script teaching channel man. keep up the good work!
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()
is he feeding you? cuz i see you on every video
@@reaklaz i'm his helper
@@osakadev what does the "pseudo" mean
also your comments are really helpful, thanks
@@jvdeonyourblock pseudorandom in this case, means "numbers NOT REALLY random", cuz computers cannot generate real random numbers
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
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.
these tutorials are really helpful
(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
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!!!
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)
"MouseButton1Click" is not even a thing?
@JustASimpleMan07 It has minor differences to "Activated"
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
Ive gone from nothing to learing how to give my friends a gambling addiction thanks man
💀lol
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)
doesnt make sense to add rarities if all the values have the same chance of being chosen.
@@KaYi25fr
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)
Very creative but what does GH mean?
@@maxinkowski4845 its just random numbers from my keyboard it is a variable and doesn't have a specific meaning on my case.
Correct me if I'm wrong btw
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
-- 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()
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.
@@grainter5 huh
@@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
An advice from me is to write down all the events you learned in a book or document
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
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
I can't believe I'm already here, thank you so much!
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.
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
good video 👍👍
its crazy how it went from 50k + to 26k wow
i love your tutorials it helped me
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
I made an epilepsy block 😀
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
That kinda looks like python code ngl
hakari
MAKE A SLOT MACHINE
I made a button that has a 1/10 chance to turn a screen yellow! Amazing tutorials btw
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.
6:35 u can also change the baseplate color using the following script
local Baseplate = game.Workspace.Baseplate
Baseplate.BrickColor = BrickColor.Random()
BrickColor.Random() limits the amount of colors, now the way he did is absolutelly any color out of the over 765 the game has.
nice video lenght
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
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)
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
i also love this local dice = math.random(1, 6)
local d = math.random(1, 6)
print("And The Dice Roll Is... ".. dice + d)
local money = 1782300
local eggCost = 20000
while money >= eggCost do
local chance = math.random(1, 100)
if chance
I wanna ask something the "if chance
elseif chance
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
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)
--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.
looks like a python script ngl
Thank you so much! I made a RNG button!
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!
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
Will this work to make a horror game where the number is the monster that appears?
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
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)
woahh
show off
@@TANER845 huh?
That actually made sense
@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
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)
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
haha cool
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)
i made that someblock simulate what i have got a common or a rare or a godly js like mm2 ur the best
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
(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)
uhm
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
The Root to Gambling Love it. Great video learned how to make a chance system and gamble...
randomNumber = math.random(1, 10)
print(randomNumber)
if randomNumber
Hey, Brawldev I think going a little bit too fast especially in a Roblox studio script beginners guide
best ever scriping tutorial I have seen
9:11 he he he
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
cant you just use random variable instead of 3 since they do they exact same thing 7:50
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
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)
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)
(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
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)
and how is it useful?
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
"a six-sided die and when we roll this die its going to land on a number between 1 and 6"
OH REALLY
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
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
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
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])
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()
do i make a schizophrenia themed game bc i can make the material and color change as fast as i want
Why this video is 9:11 long😅
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
local shinypokemon = math.random(1, 5)
if shinypokemon == 5 then
print("Shiny Pokemon has appeared!")
else
print(shinypokemon)
end
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
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.
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)
]]
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
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
local randomNumber = math.random(1,2)
if randomNumber == 1 then
print("wow")
elseif randomNumber == 2 then
print("oh")
end
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)
Lol, I made that whenever I touch the TouchPart, then teleportPart is going to teleport to the random location based on random numbers, I'm so proud.
local touchPart = script.Parent
local teleportedPart = touchPart:FindFirstChild("TeleportPart")
local canTouchPart = true
local function randomPosGen()
local xPos = math.random(1, 30)
local yPos = math.random(1, 5)
local zPos = math.random(1, 30)
return Vector3.new(xPos, yPos, zPos)
end
local function tpPartOnTouch(otherpart)
if teleportedPart and canTouchPart == true then
local randomPos = randomPosGen()
teleportedPart.Position = randomPosGen()
canTouchPart = false
task.wait(2)
canTouchPart = true
end
end
touchPart.Touched:Connect(tpPartOnTouch)
-- LEARNING OBJECTIVE:
local function roll()
local randomNumber = math.random(0, 1000)
if randomNumber >= 0 and randomNumber < 700 then
print("COMMON!")
elseif randomNumber >= 700 and randomNumber < 900 then
print("RARE!!")
elseif randomNumber >= 900 and randomNumber
Who else got 2 first try when testing random?
took a little minute to figure out but this has the block randomly move
local brick = game.Workspace.brick
while true do
local xValue = math.random(-1, 1)
local yValue = math.random(-1, 1)
local zValue = math.random(-1, 1)
brick.Position = Vector3.new(xValue, yValue, zValue)
task.wait(1)
end
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
I have a tip for you guys, when doing math.random just use interval notation
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)
Cant you also do this?
local baseplate = game.Workspace.Baseplate
while true do
baseplate.BrickColor = BrickColor.Random()
wait(10)
end
--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
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
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.
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
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()
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
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)
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)
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)
GAMBLING RAHHH
while true do
wait("2")
local Gambling = math.random(1, 150)
print(Gambling)
end
local wall = game.Workspace["The Wall"]
while true do
local transparency = math.random()
wall.Transparency = transparency
task.wait(0.5)
end
I made a slots machine, if you get any 3 numbers together you will get a small prize, and if all 3 numbers are 7's then you will get a jack pot. a single 10 will grant you a free spin and non matching numbers will respond with bad luck
local value1 = math.random(1, 10)
local value2 = math.random(1, 10)
local value3 = math.random(1, 10)
if true then
print(value1, value2, value3)
end
if value1 == 7 and value2 == 7 and value3 == 7 then
print("Jackpot!")
elseif
value1 == value2 and value2 == value3 then
print("You got a small prize!")
elseif value1 == 10 or value2 == 10 or value3 == 10 then
print("You got a free spin!")
else
print("Bad luck!")
end