Events - Roblox Beginners Scripting Tutorial #13 (2024)

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

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

  • @osakadev
    @osakadev 6 месяцев назад +112

    Summary:
    An event is a way to listen to an action occurring within the game and execute code once it is triggered.
    More technical data:
    1. Ways to listen to events:
    - :Connect(): Listen to the event forever until the connection is disconnected.
    - :Once(): Listens for the event only once and disconnects automatically, and does not run again.
    - Wait(): Waits for the event to occur by blocking the code below where the event is waiting to be fired
    - ConnectParallel(): Used in parallel luau with actors
    2. Event data type:
    Event data types are called RBXScriptSignal, while connections (when using :Connect() or otherwise), are called RBXScriptConnection.
    3. Differences between RBXScriptSignal and RBXScriptConnection
    RBXScriptSignal are events that can be listened to with :Connect() or the other forms mentioned above. While RBXScriptConnection, is a connection that roblox gives us when we are listening to an event, it has a method called :Disconnect() that serves to stop listening to that event.

    • @الخلبوصة
      @الخلبوصة 6 месяцев назад +3

      What does " Listen to the event forever" mean?
      Does it mean like the function will run everytime the event is fired?
      And how to disconnect the connection?

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

      @@الخلبوصة it means that i will stay listening to the event in memory until it gets disconnected. And to disconnect it you do:
      local event = someEvent:Connect(function()end)
      event:Disconnect() -- disconnects the event, it wont be listening to the event in memory

    • @الخلبوصة
      @الخلبوصة 6 месяцев назад +3

      Your explanation is clear and to the point. Thank you so much!
      Keep posting these summary comments in every video BrawlDev uploads, you don't know how beneficial they are to me.
      Didn't know that there are type of things called Once, Wait and ConnectParallel. And I now understand how they work!

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

      perfect for my smooth brain

    • @AlexanderEdwards-x8e
      @AlexanderEdwards-x8e 3 дня назад

      @@osakadev I’m so confused by the PartIsTouched == false then PartIsTouched=false
      Can someone please explain it to me?

  • @Cateatschips
    @Cateatschips 6 месяцев назад +61

    Now I want you to iimagine you're playing Minecraft and your exploring a jungle temple filled with all these trip wires that are inside of the temple, you decide to step on it and it triggers a dispenser that shoots you with multiple arrows that you didnt see coming at all

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

      Literally minecraft

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

      Now I see how they code it (most likely because there is a difference between coding language)

    • @AlexanderEdwards-x8e
      @AlexanderEdwards-x8e 3 дня назад

      @@ZoneBlox I’m so confused by the PartIsTouched == false then PartIsTouched=false
      Can someone please explain it to me?

    • @BottledAxolotl
      @BottledAxolotl 3 дня назад

      @AlexanderEdwards-x8e It's supposed to be:
      if partIsTouched == false then
      partIsTouched = true

    • @AlexanderEdwards-x8e
      @AlexanderEdwards-x8e 3 дня назад

      @BottledAxolotl but I don’t get it, so if there is no one touching the part, then there is someone touching the part

  • @Blisker
    @Blisker 5 месяцев назад +110

    0:07 today is actually my birthday lol

    • @okinawakor
      @okinawakor 4 месяца назад +9

      hsppy late birthday bro

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

      thought i was the only one watching this later

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

      @@inoxxz same

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

      guess im the most late here

    • @Architect-u2g
      @Architect-u2g 4 месяца назад +1

      Happy Late Birthday

  • @KomKom.i
    @KomKom.i 6 месяцев назад +47

    I've been watching your guide but never really posted my learning objectives but I'm really proud of what I did today so here I am posting it in case it helps someone :D!
    So basically I wanted to make some blocks that changed a sphere's color when you touch them. I created 7 different colors (Green, red, yellow, blue, pink, purple and white) and here is the script I made:
    local Ball = game.Workspace.TestColor.Sphere
    local green = game.Workspace.TestColor.Green
    local pink = game.Workspace.TestColor.Pink
    local purple = game.Workspace.TestColor.Purple
    local blue = game.Workspace.TestColor.Blue
    local red = game.Workspace.TestColor.Red
    local yellow = game.Workspace.TestColor.Yellow
    local white = game.Workspace.TestColor.White
    local greent = false
    local pinkt = false
    local purplet = false
    local bluet = false
    local redt = false
    local yellt = false
    local whitet = false
    -- the t after every color basically stands for "touched"
    -- The next part is basically the same as the video shows but insted of printing the part that touched I changed the ball's color
    green.Touched:Connect(function(otherPart)
    if greent == false then
    greent = true
    Ball.BrickColor = BrickColor.new("Mint")
    wait (3)

    greent = false
    end
    end)
    pink.Touched:Connect(function(otherPart)
    if pinkt == false then
    pinkt = true
    Ball.BrickColor = BrickColor.new("Carnation pink")
    wait (3)
    pinkt = false
    end
    end)
    purple.Touched:Connect(function(otherPart)
    if purplet == false then
    purplet = true
    Ball.BrickColor = BrickColor.new("Alder")
    wait (3)
    purplet = false
    end
    end)
    blue.Touched:Connect(function(otherPart)
    if bluet == false then
    bluet = true
    Ball.BrickColor = BrickColor.new("Cyan")
    wait (3)
    bluet = false
    end
    end)
    red.Touched:Connect(function(otherPart)
    if redt == false then
    redt = true
    Ball.BrickColor = BrickColor.new("Persimmon")
    wait (3)
    redt = false
    end
    end)
    yellow.Touched:Connect(function(otherPart)
    if yellt == false then
    yellt = true
    Ball.BrickColor = BrickColor.new("Cool yellow")
    wait (3)
    yellt = false
    end
    end)
    white.Touched:Connect(function(otherPart)
    if whitet == false then
    whitet = true
    Ball.BrickColor = BrickColor.new("Institutional white")
    wait (3)
    whitet = false
    end
    end)

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

      yo i dont want to steal your idea but i tried it and it really helped me understand more abou this topic thanks

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

      BRO CALM DOWN

    • @KomKom.i
      @KomKom.i 5 месяцев назад +1

      @@rafaeldossantos1998 Happy to hear that ^^!

    • @KomKom.i
      @KomKom.i 5 месяцев назад +1

      @@UserBananaIDK hehe

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

      That's a cool script ! And i was wondering why do you keep "otherPart" in each function parameter

  • @Lag_troll_WOT
    @Lag_troll_WOT 5 месяцев назад +7

    this is very useful, as a dev myself I really need all the info I can get for scripting since its hell to learn and this helps a lot!

    • @AlexanderEdwards-x8e
      @AlexanderEdwards-x8e 3 дня назад

      I’m so confused by the PartIsTouched == false then PartIsTouched=false
      Can someone please explain it to me?

  • @c.e.2867
    @c.e.2867 4 месяца назад +19

    Your Tutorials are so helpful !!
    I started scripting 2 days ago and this is what I did:
    This is a color changing and material changing event :)))
    local touchPart = game.Workspace.TouchPart
    touchPart.Touched:Connect(function()
    print (“This part is touched.”)
    if partIsTouched == false then
    partIsTouched = true
    touchPart.Material = Enum.Material.Neon
    print(“Neon.”)
    touchPart.BrickColor = BrickColor.Random ()
    print(“Color changed to:” ..tostring(touchPart.BrickColor))
    wait (5)
    partIsTouched = false
    touchPart.Material = Enum.Material.Mud
    print(“Back to normal!”)
    end
    end)

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

      use task.wait, it has less load on the server if u do (difference is task.wait waits for server to catch up and wait forces the server to stop and do it absolutely in 5 seconds which can cause more lag/issue for the server

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

      thank you. this helped me understand it better

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

      u didnt add PartIsTouched == false at first

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

      i think you forgot to add variables, does it still work tho?

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

      how im struggling so hard

  • @mathbrah
    @mathbrah 5 месяцев назад +8

    11:31 my understanding on why you have to set partIsTouched = true even when you have task.wait(2), is that the event is always firing infinitely fast. An analogy I made is that the first time the event fires is like the first fish in a fish school to cross the finish line. If partIsTouched = true wasn't there, then the second fish will still instantly cross the finish line since the event is always firing. Thus, we have to set the relative global variable partIsTouched to true to prevent any more event firings to get past that if statement.

  • @demoblox2924
    @demoblox2924 5 месяцев назад +13

    something IMPORTANT he forgot to mention is if you go to the view tab then open object browser it tells you lots about events and other things when scripting.

    • @AlexanderEdwards-x8e
      @AlexanderEdwards-x8e 3 дня назад

      I’m so confused by the PartIsTouched == false then PartIsTouched=false
      Can someone please explain it to me?

    • @questionmark.4444
      @questionmark.4444 2 дня назад

      ​@AlexanderEdwards-x8e "PartIsTouched == false" checks IF it's false. "PartIsTouched = false" STATES that it's false. Basically, == checks it, while = declares it

    • @AlexanderEdwards-x8e
      @AlexanderEdwards-x8e 2 дня назад

      @@questionmark.4444 ahhh thanks

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

    1:16 brawldev is a robot confirmed??

  • @noobythenoobking
    @noobythenoobking 6 месяцев назад +1

    i wasnt expecting another episode today WWWW!!!
    keep up with the amazing content!

  • @pulbiberonur2836
    @pulbiberonur2836 5 месяцев назад +3

    i used Touch event to make a part change its color to green from red and found TouchEnded event and used it to make it red whenever you arent touching it since it was pretty self explanetory
    ive already gottren some education in coding in diffirent languages like phyton or and seen about this kind of ui before too so i knew about coding or at least how it works and stuff. this episode is the first episode with features that i never saw before. i hope it wont be a problem lol. btw its crazy that you only have 10k subs when im watching. gl w tht

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

      I'm learning python rn and it's pretty cool, I think I can learn Lua too :)

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

    today is my bday and i just watched the example of the start of the video lol

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

    This is my favorite video of the beginner series so far!

  • @sigma-n4f8d
    @sigma-n4f8d Месяц назад +2

    Made a speedboost + 10 seconds timer so the speedboost will stop when it reaches to 0
    local Speedboost = script.Parent
    Speedboost.Touched:Connect(function(otherpart)
    local humanoid = otherpart.Parent:FindFirstChild("Humanoid")
    if humanoid then
    humanoid.WalkSpeed = 100
    if humanoid.WalkSpeed == 100 then
    for i = 10, 0, -1 do
    task.wait(1)
    print("Timer ", i)
    if i == 0 then
    print("Speedboost is over!")
    humanoid.WalkSpeed = 16

    end
    end
    end
    end
    wait(10)
    humanoid.WalkSpeed = 16
    end)

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

    omg its fr my birthday today what a blessing

  • @AlexanderEdwards-x8e
    @AlexanderEdwards-x8e 3 дня назад +1

    From 9:34 to 10:45 I was bamboozled

  • @LipeButCool
    @LipeButCool 2 дня назад +1

    Kinda proud of what I did today basically I made a wedge that changes color when u press it or whatever had to do some de-bugging and this is what happened :D
    local wedge = game.Workspace.Wedge
    local partIsTouched = false
    wedge.Touched:Connect(function()
    if partIsTouched == false then
    partIsTouched = true
    print("Touched")
    wedge.BrickColor = BrickColor.new("Really red")
    wait(1)
    wedge.BrickColor = BrickColor.new("Really blue")
    print("Untouched")
    partIsTouched = false
    end
    end)

  • @lusaxcvq
    @lusaxcvq 6 месяцев назад

    7k subscribers, Congrats 🎉❤

  • @WormyGerber
    @WormyGerber 9 дней назад

    a good learning activity is at the end try to explain the code to urself and see if u can explain every bit of function the code does for what reason. this is a good activity to familiarise urslef with scripting!

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

    local touchPart = game.Workspace.Part
    local isTouched = false
    game.Workspace.Part.Touched:Connect(function(otherPart)
    local x = math.random(1, 10)
    local y = math.random(1, 10)
    local z = math.random(1, 10)
    if isTouched == false then
    isTouched = true
    print(otherPart.Name)
    touchPart.CFrame = CFrame.new(x, y, z)
    task.wait(.5)
    isTouched = false
    end

    end)
    its such a basic script, but it made me feel so proud when i managed to figure it out by myself. basically what it does is everytime you touch a part, it will teleport to a random position within a 1 to 10 value range for each axis. this could probably be done in a better way but idc, i've been trying to learn roblox game dev ever since i was a little kid, and finally getting the impulse to ACTUALLY begin learning the proper way makes me feel so happy! game dev is literally my DREAM profession! thanks brawldev! :D

    • @memebirbs
      @memebirbs 22 дня назад

      actually this script is really cool! its really impressive you made this on your own, i took a little spin to where it changes color instead of moving

    • @Contentdeleted99998
      @Contentdeleted99998 22 дня назад

      @@memebirbs thanks for the little compliment! i actually improved alot from when i had posted this comment, looking back at it kinda of makes me cringe, lol.

    • @Kodul
      @Kodul 10 дней назад

      ​@Contentdeleted99998 have you made your own game yet?

    • @Contentdeleted99998
      @Contentdeleted99998 10 дней назад

      @@Kodul i made a few meme games for my friends, nothing i can call real games yet. i am working on an actual game for a change although i actually had quite a few projects that could be considered real enjoyable games but i gave up on them cuz i cant model that well. rn im just trying to focus on getting atleast one of them done.

    • @Kodul
      @Kodul 10 дней назад

      ​@Contentdeleted99998 I wish you good luck

  • @Saydayso
    @Saydayso 6 месяцев назад +1

    amazing video im just curious are u gonna make another new advanced series since u also made a new beginners series

    • @BrawlDevRBLX
      @BrawlDevRBLX  6 месяцев назад

      There won't be a new advanced series

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

    In 4:51 how did the function knew or that roblox new the parameter is player name???

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

      one of those things that are built into Roblox. just like game and workspace. roblox knows what all of these things already are. we are constantly editing our game which is why we have to tell roblox what all these edits mean.
      example, we have a part named myPart
      we can't just write myPart and expect roblox to know what it is because we've edited something.
      that's why we tell roblox what it is by saying:
      local myPart = game.Workspace.Part

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

    i made a simple thing where when you touch a hitbox, another part changes color and has a cooldown of 3 seconds
    local touchPart = game.Workspace.TouchPart
    local isPartTouch = false
    touchPart.Touched:Connect(function(otherPart)
    if isPartTouch == false then
    isPartTouch = true
    game.Workspace.fallpart.BrickColor = BrickColor.Random()
    task.wait(3)
    isPartTouch = false
    end
    end)
    this is my first time sharing my work, only cause im genuinely proud of this

  • @Hooman_bean1
    @Hooman_bean1 27 дней назад +2

    I made a print statement that says “ y/n has joined the server!”
    And a block that makes the player die (:

  • @الخلبوصة
    @الخلبوصة 6 месяцев назад

    I thought there's nothing I don't know regarding Events, until this video released.
    Thank you brawldev!

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

    Amazing tutorials love them

  • @JustEvanC
    @JustEvanC 8 дней назад +1

    Thanks so much for your help, I have tried other tutorials and failed to learn anything or very little. Anyways this is what I did in Studio!
    local TouchPart = game.Workspace.KillTest
    local partIsTouched = false
    TouchPart.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    partIsTouched = true
    task.wait(1)
    TouchPart.BrickColor = BrickColor.new("Really red")
    task.wait(1)
    TouchPart.BrickColor = BrickColor.new("Bright blue")
    if partIsTouched == true then
    print("The function has been completed")
    end
    end
    end)

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

    took me very long to figure this out but i got it
    local touchpart = game.Workspace.TouchPart
    local partistouched = false
    local partistouched = true
    touchpart.Touched:Connect(function(otherpart)

    if partistouched == true then

    touchpart.BrickColor = BrickColor.Random()




    end

    touchpart.TouchEnded:Connect(function(otherpart)


    if partistouched == true then


    touchpart.BrickColor = BrickColor.Gray()


    end


    end)



    end)

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

    bro this tutorial is so actually gooddd, i didn't know anything with scripts now im playing w them!!!!

  • @Hexplaysroblox
    @Hexplaysroblox 6 месяцев назад +2

    local touchpart = game.Workspace.touchpart
    local partistouched = false
    local partmaterial = false
    touchpart.Touched:Connect(function(otherpart)
    if partistouched == false then
    partistouched = true
    print(otherpart.Name)

    task.wait(2)
    partistouched = false

    if partmaterial == false then
    touchpart.Material = "Rock"
    task.wait(2)
    partmaterial = true
    else
    touchpart.Material = "Plastic"
    end
    end
    end)

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

    Thanks brawl dev I made a part that slowly sets its transparency to 1, then collision gets turned off. Very cool!

  • @AlexanderEdwards-x8e
    @AlexanderEdwards-x8e 3 дня назад +1

    I’m so confused by the PartIsTouched == false then PartIsTouched=false
    Can someone please explain it to me?

    • @xolted
      @xolted 3 дня назад

      That step is called Debouncing. The reason it's needed in this scenario is because when the Touched event is fired, there are many of the Player's parts touching the part really quickly with no cooldown. This can cause lag issues in your game. To add a Debounce in your script, you need to create a BOOLEAN variable and set it to false, like:
      local partIsTouched = false
      Then, create an If statement to check if the part is being touched or not, and set the variable to TRUE once it is being touched:
      if partIsTouched == false then
      partIsTouched = true
      print(otherPart.Name)
      Next, set it back to FALSE once it is NOT being touched anymore:
      if partIsTouched == false then
      partIsTouched = true
      print(otherPart.Name)
      task.wait(2) -- you can edit how long you want the cooldown to be for the Touched event to occur here
      partIsTouched = false
      end

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

    could you tell me why it printed Player instead of the playername.Thankyou

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

      You write print(player) and not print("player")

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

      @@Pizzadude690 thank you

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

    0:07 i dont need to imagine it, because it is today.

  • @RNC-o6u
    @RNC-o6u 2 месяца назад +2

    I spent like 30 minutes perfecting this lol but here is my art work that I'm proud off.
    local touchPart = game.Workspace.Eek
    local originalMaterial = touchPart.Material
    local partIsTouched = false
    touchPart.Touched:Connect(function(otherPart)
    if not partIsTouched then
    partIsTouched = true
    print("Ah hah, metal!")
    task.wait(2)
    touchPart.Material = Enum.Material.Metal
    task.wait(2)
    print("Oh? You want it to become the original material and a different color? Alright.")
    task.wait(2)
    touchPart.Material = originalMaterial
    task.wait(2)
    touchPart.BrickColor = BrickColor.new("Cyan")
    task.wait(2)
    print("You want more!?!? Jeez.")
    task.wait(2)
    touchPart.Transparency = 0.5
    task.wait(2)
    print("Oh now what? You want the transparency back to normal? Ugh.")
    task.wait(2)
    touchPart.Transparency = 0
    task.wait(2)
    print("Are you FINALLY done now?!?")
    task.wait(2)
    print("Finally...")
    partIsTouched = false
    end
    end)

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

    im so glad this script accually worked, thank you so much for making a free and easy way to learn coding
    local touchPart = game.Workspace.touchPart
    local partistouched = false
    touchPart.Touched:connect(function(player) -- makes the part unAnchored when a player touches it
    if partistouched == false then
    touchPart.Anchored = false
    end
    end)

    • @samwelsh2451
      @samwelsh2451 18 дней назад

      good job bro

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

      I wish the best for you bro your pretty smart I’ve been watching all the videos and still struggling

  • @809mmor
    @809mmor Месяц назад +5

    Hi, been watching your tutorials since episode 1 and been experimenting each episode and really wanted to share it but i'm shy lol but i'm proud of what i was able to do for this episode so might as well share it:
    local touchPart = game.Workspace.Part
    local partTouched = false
    touchPart.Touched:Connect(function(darkGreen)
    if partTouched == false then
    partTouched = true
    for i = 0.9, 0, -0.1 do
    touchPart1.Transparency = i
    task.wait(0.1)
    end
    touchPart.Transparency = 0
    print('Dark Green!')
    end
    end)
    so like the color of the part is dark green and initially the part's transparency is 0.9 so when you touch the part, it slowly turns the transparency to 0. After the part's transparency turns to 0 then it will print the color of the part which is dark green. I used what I learnt in the Loops Episode #11 and combined it with what I learnt in this episode :>>

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

      A fix to your loop could be by adding a
      partTouched = false
      outside the if statement.

  • @EvilCuteKitteh
    @EvilCuteKitteh 6 месяцев назад

    Your guide so far has helped me understand the fundamentals better than any other guide I've tried so far! I just wanted to ask!! I see there are two unavailable videos hidden on the playlist, are these important at all? If this is the end of the playlist I want to move on to your other playlists on the more advanced topics, but I wanted to make sure there was nothing I was missing! Scripting is something I've had my mind on for many years so I'd want to learn it as best as I can!

    • @BrawlDevRBLX
      @BrawlDevRBLX  6 месяцев назад +2

      Have patience. Learning these concepts, especially the advanced ones, takes time to get really good at. And yes, there are more episodes left. The series will end around ep 17-18 and then we'll be returning back to the advanced and gui series!

    • @EvilCuteKitteh
      @EvilCuteKitteh 6 месяцев назад

      @@BrawlDevRBLX Cool! I actually peeked ahead and followed the first three videos of the advanced series just out of curiosity, and stopped after the tools episode since I had had my fun with making silly tools with what I knew. I'll definitely keep an eye out on this series first though since some of the things, though I did have a general understanding of what they did, caught me off guard with not knowing exactly how to use them!
      This has been a great learning series though! You've actually explained what each individual thing does which really helps me stay motivated and understand WHY it's actually working, which other guides I've tried to follow in the past just simply did not do and killed my motivation! Keep it up, you've got at least one person here really following along to learn!

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

    So i made my block to where if i touch the block it changes the avatar color to the color i set rather than actually chaning the block color 😆 i did this all by accident to

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

    3:54 you can do
    game.Players.PlayerAdded:Connect(function(player)
    print("A new player has joined into the game! Player:", player)
    end)
    instead if you are feeling fancy lol

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

      or
      game.Players.PlayerAdded:Connect(function(player)
      print(player.. " has joined the game.")
      end)
      if you are feeling extra fancy

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

      @@NaCubical true

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

    So I actually did touch events before I watched this tutorial and here's what I did: I went into workshop and searched up kill brick and put it into roblox studio then I went into it's script and copied the bit which looked like the touched event, after I put it into a bridge model from the workshop and made a bridge that disappears when you walk on it. here the script:
    script.Parent.Touched:Connect(function(part)
    if part.Parent:FindFirstChild("Humanoid") then
    task.wait(0.7)
    game.Workspace.WoodenBridge.CanCollide = false
    game.Workspace.WoodenBridge.Transparency = 0.5
    task.wait(4)
    game.Workspace.WoodenBridge.CanCollide = true
    game.Workspace.WoodenBridge.Transparency = 0
    end
    end)

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

    You are the besttt🎉🎉🎉

  • @GGgaming-s6u
    @GGgaming-s6u 2 месяца назад +1

    I made a block that turns green when you touch it :D local touchPart = game.Workspace.touchPart
    local partIsTouched = false
    touchPart.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    partIsTouched = true
    touchPart.BrickColor = BrickColor.new("Bright green")
    task.wait(2)
    touchPart.BrickColor = BrickColor.new("Medium stone grey")
    task.wait(2)
    partIsTouched = false
    end

    end)

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

    Hey Dude thanks for teaching me!

  • @TridentTrist
    @TridentTrist 12 дней назад

    So what I learned is that I can continuously touch your parts with my Humanoid Root Part :)

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

    change the color of the brick randomly every time u touch it
    local TouchPart = game.Workspace.TouchPart
    local partIsTouched = false
    TouchPart.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    partIsTouched = true
    print(otherPart.Name)

    TouchPart.BrickColor = BrickColor.Random()

    task.wait(3)
    partIsTouched = false
    end

    end)

  • @arg-bo3vx
    @arg-bo3vx 2 месяца назад +1

    local killbrick = script.Parent
    local cooldown = false
    killbrick.Touched:Connect(function(touched)
    local humanoid = touched.Parent:FindFirstChild("Humanoid")

    if humanoid and not cooldown then
    cooldown = true
    killbrick.BrickColor = BrickColor.new("Really red")
    task.wait(1)
    killbrick.BrickColor = BrickColor.new("Neon orange")
    task.wait(1)
    killbrick.BrickColor = BrickColor.new("Fire Yellow")
    task.wait(1)
    killbrick.BrickColor = BrickColor.new("Dark green")
    task.wait(1)
    killbrick.BrickColor = BrickColor.new("Baby blue")
    task.wait(1)
    killbrick.BrickColor = BrickColor.new("Bright purple")
    task.wait(1)
    cooldown = false
    end
    end)

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

    Made it so that my part changes its rarity (Becomes a different color and prints a rarity) when you interact with it, and it has 1 second cool-down
    local touchpart = game.Workspace.Touchpart
    local Partouched = false
    touchpart.Touched:Connect(function(otherpart)
    local z = math.random(1,100)
    if Partouched == false then
    Partouched = true
    if z

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

    local touchpart = game.Workspace.LAVA
    local partIsTouched = false
    touchpart.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    partIsTouched = true
    print(otherPart)
    otherPart:Destroy()
    task.wait(0.1)
    partIsTouched = false
    end
    end)

  • @MuhammadRao-k6q
    @MuhammadRao-k6q 2 месяца назад +1

    i made one that is a normal touched event and also a clicked event that changes color randomly
    touched event
    local WPart = game.Workspace.WPart
    local touched = false
    WPart.Touched:Connect(function(cool)
    if touched == false then
    touched = true
    WPart.BrickColor = BrickColor.Random()
    print(WPart.BrickColor)
    task.wait(2)
    touched = false
    end
    end)
    clicked event (Part Needs ClickDetector To Work)
    local WPart = game.Workspace.WPart
    local clicked = false
    WPart.ClickDetector.MouseClick:Connect(function(cool)
    if clicked == false then
    clicked = true
    WPart.BrickColor = BrickColor.Random()
    print(WPart.BrickColor)
    task.wait(2)
    clicked = false
    end
    end)

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

    local touchedpart = false
    game.Workspace.Part.Touched:Connect(function(PlayerPart)
    if touchedpart == false then
    touchedpart = true
    game.Workspace.Part.BrickColor = BrickColor.new("Really red") --cooldown
    game.Workspace.Baseplate.BrickColor = BrickColor.Random()
    task.wait(3)
    game.Workspace.Part.BrickColor = BrickColor.new("Lime green") -- off cooldown
    touchedpart = false
    end
    end)

  • @Midnight.debates
    @Midnight.debates 2 месяца назад

    I edited the TouchedEvent code and added this which basically when the player has touched the part, the transparency will be set to 1 and CanCollide will be off, once 2 second cooldown is done, it will change back to Transparency 0 and the part will have CanCollide On: local hitPart = game.Workspace.HitPart
    local partIsTouched = false
    hitPart.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    partIsTouched = true
    print(otherPart.Name)
    hitPart.Transparency = 1
    hitPart.CanCollide = false
    task.wait(2)
    partIsTouched = false
    hitPart.Transparency = 0
    hitPart.CanCollide = true
    hitPart.BrickColor = BrickColor.new("Really red")
    end
    end)

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

    local touchPart = game.Workspace.touchPart
    local partTouched = false
    touchPart.Touched:Connect(function(otherPart)
    if partTouched == false then
    partTouched = true
    touchPart.BrickColor = BrickColor.Random()

    wait(2)
    partTouched = false
    end

    end)
    local baseplate = game.Workspace.Baseplate
    game.Players.PlayerAdded:Connect(function(player)
    if game.Players.PlayerAdded:Connect() then
    baseplate.BrickColor = BrickColor.Random()
    end
    end)
    *OR YOU CAN USE CODE FROM LAST VIDEO AND MAKE IT LOOP"
    local baseplate = game.Workspace.Baseplate
    game.Players.PlayerAdded:Connect(function(player)
    for player = 1, 9999999 do
    baseplate.BrickColor = BrickColor.Random()
    wait(1)
    end
    end)

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

    i needed a LOT of practicw with this one. here they are (they work combined as a part that hates when it gets touched and wants u to leave and calls u lil bro idk.
    game.Players.PlayerAdded:Connect(function(player)
    print("get out please")
    print(player)
    end)
    game.Players.PlayerRemoving:Connect(function(player)
    print("yippe")
    end)
    local t = game.Workspace.touch
    local touched = false
    t.Touched:Connect(function(otherpart)
    if touched == false then
    touched = true
    task.wait(1)
    touched = false
    end
    if touched == true then
    print("EW I SAID GET OUT NOT TOUCH ME LIL BRO")
    else
    print("i said get out lil bro")
    end
    end)

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

      you can actually do
      print(player, "get out please")
      so it says your name and says get out please

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

      @@reaklaz oh cool, ill note that thx

    • @MG-ji1ms
      @MG-ji1ms 5 месяцев назад

      very bad script ngl

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

      @@MG-ji1ms hes new what did you expect?

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

      @@MG-ji1ms man constructive criticism and move on with ur day

  • @MR-VOXELATOR117
    @MR-VOXELATOR117 2 месяца назад +1

    i was making my script :
    local TouchPart = game.Workspace.TouchPart
    TouchPart.Touched:Connect(function(OtherPart)
    print(OtherPart.Name)
    end)
    and for some reason it didnt work then when i hovered my mouse over the variable it highlighted the TouchPart the second one then i renamed the variable then it turned out you cant have the same name of the variable as a part why is that

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

      You need to have small t when making a variable so that it is not the same as the part

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

      @@SkibidiDaca123 ohk

    • @xolted
      @xolted 3 дня назад

      @@MR-VOXELATOR117 you CAN have a variable the same name as a part. The reason yours didn't work is because you probably didn't even touch the part in game. The script itself will work.

  • @kuanjarlo
    @kuanjarlo 6 месяцев назад +1

    wish I could show you the progress I've made on my game, I'm making mad progress in just a week

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

    local touchPart = game.Workspace.TouchPart
    local partIsTouched = false
    local baseplate = game.Workspace.Baseplate
    touchPart.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    partIsTouched = true
    baseplate.BrickColor = BrickColor.new("Really red")

    if
    touchPart.TouchEnded then
    touchPart.TouchEnded:Connect(function()
    partIsTouched = false
    baseplate.BrickColor = BrickColor.new("Dark grey metallic")
    end)
    end
    end
    partIsTouched = false

    end)

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

    Now this is getting interesting, bro just teached me how to do a hitbox!!!

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

    A trick obby part (this took awhile)
    local TrickPart = game.Workspace.TrickPart
    TrickPart.Touched:Connect(function(whatTouched)
    if whatTouched.Parent:FindFirstChild("Humanoid") then-- this detects if what touched Trik part is part of the player
    while TrickPart.Transparency < 1 do
    TrickPart.Transparency = math.min(TrickPart.Transparency + 0.1, 1)-- makes sure Transparency can't be more than 1
    wait(0.25)
    end
    TrickPart.CanCollide = false
    wait(5)
    TrickPart.CanCollide = true
    TrickPart.Transparency = 0
    end
    end)

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

    It works for me in this way:
    local touchPart = game.Workspace.TouchPart
    local canTouchPart = true
    local function isTouchedPart(otherpart)
    if canTouchPart == true then
    canTouchPart = false
    print(otherpart.Name)

    task.wait(2)
    canTouchPart = true
    end
    end
    touchPart.Touched:Connect(isTouchedPart)
    Also amazing tutorial!

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

    local touchPart = game.Workspace.Touchpart
    local partistouched = false
    touchPart.Touched:Connect(function(otherpart)
    if partistouched == false then
    partistouched = true
    print(otherpart.Name)
    task.wait(0.25)
    partistouched = false
    if partistouched == false then
    touchPart.BrickColor = BrickColor.new("Medium stone Grey")
    partistouched = true
    touchPart.BrickColor = BrickColor.new("Really red")
    task.wait(0.75)
    partistouched = false
    touchPart.BrickColor = BrickColor.new("Medium stone Grey")
    end
    end
    end)
    Thank you so much Brawl dev, Im really dedicated to becoming a game developer and these tutorials are great, Thank you :)

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

    --a cool example of triggering events!
    local part = game.Workspace.TouchedPart
    local touchedpart = false
    part.Touched:Connect(function(TouchedPart)
    local humanoid = TouchedPart.Parent:GetFullName()
    if touchedpart == false then
    touchedpart = true
    print(TouchedPart.Parent)

    task.wait(2)
    touchedpart = false
    end
    end)

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

    local touchPart = game.Workspace.TouchPart
    local partIsTouched = false
    touchPart.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    partIsTouched = true
    print(otherPart.Name)

    task.wait(3)
    partIsTouched = false
    end
    end)
    touchPart.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    partIsTouched = true
    touchPart.BrickColor = BrickColor.new("Sea green")
    task.wait(3)
    touchPart.BrickColor = BrickColor.new("Really red")
    partIsTouched = false
    end
    end)

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

    the fact that my birthday is in 2 days is crazy 0:05

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

    OK THIS IS LITERALLY WHY I STARTED LEARNING SCRIPTING
    with no prior scripting learning by your 13th tutorial of the play list i can finally do this:
    local AntiFog = game.Workspace.AntiFogPart
    local AntiTouched = AntiFog.Touched:Connect(function(bodypart)
    AntiFog.CanCollide = false
    AntiFog.Transparency = 1
    if AntiFog.CanCollide == false then
    game.Lighting.Atmosphere.Density = 0.0
    end
    end)
    a part called 'AntiFogPart' is placed in a building so theres no fog in the building'
    local AntiFog = game.Workspace.AntiFogPart
    local OnFog = game.Workspace.OnFogPart
    local OnTouched = OnFog.Touched:Connect(function(bodypart)
    OnFog.CanCollide = false
    OnFog.Transparency = 1
    if OnFog.CanCollide == false then
    game.Lighting.Atmosphere.Density = 0.6
    end
    end)
    a part called 'OnFogPart' is placed in the spot where it teleports me outside of the building, despite now reaching my goal ill carry on learning how to script, but i have to say, THANK YOU!

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

      oh btw, i was struggling so i clicked 'tab' and it auto pasted a lot of the struggle in for me (idk how else to make the script work without some of the unnecissery stuff)

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

    A contraption you go in and get smushed by a large piece of metal:
    local touchpart = workspace["Squish contraption"].TouchPart
    local metal = workspace["Squish contraption"].Metal
    local wall = workspace["Squish contraption"].Wall
    metal.Anchored = true
    local partisTouched = false
    touchpart.Touched:Connect(function(otherpart)
    if partisTouched == false then
    partisTouched = true
    print("uh oh, here it comes.")
    wall.CanCollide = true
    wall.Transparency = 0
    metal.Anchored = false
    task.wait(.1)
    partisTouched = false
    end
    end)

  • @a_loozer4382
    @a_loozer4382 15 часов назад

    day4, this one also was really cool to learn. i see how both of these are insanely useful allready, especially with creating objects that fall on touch like most obbies have. Aswell as join messages to players. heres what i cooked up
    local platform1 = game.Workspace.Platform1
    local partIsTouched = false
    platform1.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    partIsTouched = true

    task.wait(1)
    print("the part is going to fall!")
    platform1.BrickColor = BrickColor.new("Really red")
    platform1.Transparency = 0.5
    task.wait (2)
    platform1.Anchored = false
    platform1.Transparency = 0.75
    print("the part fell!")
    task.wait (1)
    platform1.Transparency = 1
    end
    end)

  • @lesserman9851
    @lesserman9851 5 месяцев назад +3

    im tweaking

  • @janjaap58
    @janjaap58 24 дня назад

    9:31 Ok so I didn't understand the "partIsTouched" part at first but for the people that struggle like me I'm pretty sure what it does is he makes the variable FALSE and when you touch the part it can only do the second line when the variable is FALSE and it is so it prints the part name but it first makes it TRUE and so when you move while it's giving the part name and waiting a second it cannot give the name again because it is still on TRUE and after the waiting it resets too FALSE.
    Sorry you prob still don't understand it if you didn't alr.

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

    made this into two parts just to test out the cooling time for when you touch a part. (in this case i have made it the spawn location)
    game.Players.PlayerAdded:connect(function(player)
    print('a new player has joined')
    print(player)
    end)
    local spawnTouch = game.Workspace.SpawnLocation
    spawnTouch.touched:Connect(function(otherpart)
    print(otherpart.name)
    end)
    the script bellow includes cooling time. :D
    game.Players.PlayerAdded:connect(function(player)
    print('a new player has joined')
    print(player)
    end)
    local spawnTouch = game.Workspace.SpawnLocation
    local spawnIsTouched= false
    spawnTouch.touched:Connect(function(otherpart)
    if spawnIsTouched == false then
    spawnIsTouched = true
    print(otherpart.Name)

    task.wait(2)
    spawnIsTouched = false
    end
    end)
    just want to add that these videos are so great! easy to follow. here and there i can feel a small challenge but its not so frustrating to the point i want to stop. maybe they way brawlDev breaks it down is just to good!

  • @SiamStamporoski
    @SiamStamporoski 12 дней назад

    TY so much i made my own killbrick with this

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

    for some reason the first event code to do with touchpart in the vid insta kills me when i touch it even though i only asked it to print name? can i get some help please

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

    I've done this but once the touchPart is touched once it doesn't work again and I was wondering if you would be able to let me know what I need to do for it to continuously work (so that every time the touchPart is touched it turns transparent)
    local touchPart = game.Workspace["Touch part"]
    local partIsTouched = false
    touchPart.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    partIsTouched = true
    touchPart.Transparency = 0.5
    if partIsTouched == true then
    task.wait(2)
    touchPart.Transparency = 0
    end
    task.wait(2)
    end
    end)

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

      you gotta remove the second task.wait

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

    11:45 when you said "You can even change the color of the part and even make it turn back after a period of time," I laterally did that exactly before you even said that 😭
    Here's the code:
    -- Making it so when a player touches the "Bad Brick" it makes it red
    local touchBadPart = game.Workspace.BadPart
    local BadPartIsTouched = false
    touchBadPart.Touched:Connect(function(otherPart)
    if BadPartIsTouched == false then
    BadPartIsTouched = true

    touchBadPart.BrickColor = BrickColor.new("Really red")
    wait(2)
    touchBadPart.BrickColor = BrickColor.new("Medium stone grey")

    task.wait(2)
    BadPartIsTouched = false
    end
    end)

  • @fnumtxer
    @fnumtxer 7 дней назад +1

    local touchPart = game.Workspace.TouchPart
    local partIsTouched = false
    touchPart.Touched:Connect(function(otherpart) --sense anything touching part
    if partIsTouched == false then
    partIsTouched = true
    print(otherpart) -- show what touched part
    touchPart.Size = touchPart.Size + Vector3.new(1,1,1) --grow
    wait(2) -- debounce
    partIsTouched = false
    end
    end)

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

    normally when i want to learn to script i quit after 1 or 2 eps and now im up to 13

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

    Bro you are the best scripting teacher ever

  • @musaabbas9179
    @musaabbas9179 6 месяцев назад +1

    local touchPart = game.Workspace.TouchPart
    local partIsTouched = false
    local colorChangeAllowed = false
    touchPart.Touched:Connect(function(otherPart)
    if partIsTouched == false then
    partIsTouched = true
    print(otherPart.Name)
    touchPart.BrickColor = BrickColor.new("Medium red")
    -- Wait for 2 seconds
    task.wait(2)
    -- Allow color change on next touch
    colorChangeAllowed = true
    partIsTouched = false
    elseif colorChangeAllowed then
    touchPart.BrickColor = BrickColor.new("Medium blue")
    colorChangeAllowed = false

    -- Wait for 2 seconds
    task.wait(2)
    end
    end)

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

    I will post my first script here, so I'm sorry if it's too long. This script will basically change the part called "TouchPart" to blue if you touch it once, to yellow if you touch it twice, to red if you touch it three times, and finally destroy the object
    Note 1: Instead of using three different if statements, I would probably create a dictionary holding the counter values and their respective colors, something like {"1": Cyan, "2": Yellow, "3": Red}. The code would be more optimized and readable, but I don't know how to do it in Lua, so yeah 😅
    Note 2: Instead of repeating the same code snippet to toggle the isTouched variable and change the color, a better practice would be to create a function. But unfortunately, I was too lazy to do it
    game.Players.PlayerAdded:Connect(function(player)
    print(player.Name .. " connected!")
    end)
    local TouchPart = game.Workspace.TouchPart
    local isTouched = false
    local Counter = 0
    TouchPart.Touched:Connect(function(otherPart)
    if isTouched == false then
    Counter += 1
    isTouched = true
    task.wait(2)
    end
    if Counter == 1 then
    TouchPart.BrickColor = BrickColor.new(0.184314, 0.67451, 1)
    isTouched = true
    task.wait(2)
    TouchPart.BrickColor = BrickColor.new(1, 1, 1)
    isTouched = false
    end
    if Counter == 2 then
    TouchPart.BrickColor = BrickColor.new(0.961, 0.804, 0.189)
    isTouched = true
    task.wait(2)
    TouchPart.BrickColor = BrickColor.new(1, 1, 1)
    isTouched = false
    end
    if Counter == 3 then
    TouchPart.BrickColor = BrickColor.new(0.769, 0.157, 0.110)
    isTouched = true
    task.wait(2)
    isTouched = false
    TouchPart:Destroy()
    end
    end)

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

    i made it when a player touches the coin, made by me. it disappears and then it plays some boss music and the siren alarm meme also plays and when the player turns around there is a leprechaun that says Where me gold? and its supposed to fight you.

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

    Here is a lua script that changes color every second
    -- Get a reference to the part this script is in
    local part = script.Parent
    -- Function to change the color of the part when touched
    local function onTouch(other)
    -- Change the color of the part to a random color
    part.BrickColor = BrickColor.Random()
    end
    -- Connect the onTouch function to the Touched event of the part
    part.Touched:Connect(onTouch)

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

    So events automatically pass in the parameter to the connected function right? Like when you touch the part, the event passes the thing that touched the part into the function.

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

      For built-in Roblox events, yes. Custom events you'll have to do yourself, but that's a bit more complicated to do.

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

      @@BrawlDevRBLX ok Thank you so much

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

    local touchPart = game.Workspace.TouchPart
    local partIsTouched = false
    touchPart.Touched:Connect(function(otherPart)

    print(otherPart.Name)
    otherPart.Color = Color3.fromRGB(255,255, 0)

    end)
    made myself yellow
    😆

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

    I made a player count with this! And it shows the players name on a gui!

  • @nahidwin-mn1ij
    @nahidwin-mn1ij 3 месяца назад +1

    11:13 Yessir done
    local tw = game.Workspace.touchyWouchy
    local twbeingTouched = false -- boolean variable used to make a cooldown in the touched event
    tw.Touched:Connect(function(OtherPart)
    if twbeingTouched == false then -- basically runs the if statement if its touched
    twbeingTouched = true -- runs because it got touched

    print(OtherPart.Name) -- prints the name of the part that touched it.
    tw.BrickColor = BrickColor.new("Ghost grey") -- messing with the properties of the part when its touched
    tw.Material = Enum.Material.Brick
    tw.CastShadow = false
    tw.Transparency = 0.420
    task.wait(2.5)

    twbeingTouched = false -- if its stops being touched it properties will go back to normal

    if twbeingTouched == false then
    tw.BrickColor = BrickColor.new("Medium stone grey") -- rests the properties back to normal if its not touched
    tw.Material = Enum.Material.Plastic
    tw.CastShadow = true
    tw.Transparency = 0
    end
    end
    end)
    -- what this script does is if you stop touching the part after 2.5 seconds it will reset back to normal
    -- episode 13 done yessir :D.

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

    i had realy fun with the touched i realy tested to do it on my own till this part 13 but i kept getting errors thanks i finnaly made waht i wanted

  • @AdamBr-q8d
    @AdamBr-q8d 4 месяца назад

    This took me maybe 10 mins to figure out mainly due to what to use and where to put certain lines
    local partistouched = false
    local count = 1
    local TouchColor = game.Workspace.TouchColor
    TouchColor.Touched:Connect(function(otherpart)
    if partistouched == false then
    partistouched = true
    print(otherpart.Name)
    if count == 1 then
    TouchColor.BrickColor = BrickColor.Red()
    print("R")
    count = count + 1
    elseif count == 2 then
    TouchColor.BrickColor = BrickColor.Blue()
    print("B")
    count = count + 1
    elseif count == 3 then
    TouchColor.BrickColor = BrickColor.Yellow()
    print("Y")
    count = 1
    end
    wait(2)
    partistouched = false
    end
    end)
    Ur first touch will make it red, next blue then third yellow and then back to red etcc

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

    you actually can do script.parent.Touched:Connect(function() instead of local (part name) = game.workspace.(part name) ' (part name.Touched:Connect(function() parent is a thing that own it like you have script in a part so script.parent is script and the owner of it so it is the part

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

    With this tutorial i was able to make a sleeping cube that when you touch it he says "Hey!" and wakes up, i used billboard gui for the text, this is what my script looks like:
    local Cube = script.Parent
    Cube.Talk["Hey!"].Visible = false
    script.Parent.Touched:Connect(function(Speak)
    Cube.Awake.Transparency = 0
    Cube.Asleep.Transparency = 1
    Cube.Talk["Hey!"].Visible = true
    task.wait(3)
    Cube.Awake.Transparency = 1
    Cube.Asleep.Transparency = 0
    Cube.Talk["Hey!"].Visible = false
    end)

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

    This helped me.
    heres the script i made.
    local touchPart = game.Workspace.TouchPart
    local partIsTouch = false
    touchPart.Touched:Connect(function(otherPart)
    if partIsTouch == false then
    partIsTouch = true
    print("Part is touched")
    print(otherPart.Name)
    touchPart.Material = Enum.Material.Neon
    touchPart.BrickColor = BrickColor.Random()

    task.wait(2)
    partIsTouch = false
    touchPart.Material = Enum.Material.Plastic
    touchPart.BrickColor = BrickColor.new("Medium stone grey")
    print("The part is back to normal!")
    end
    end)

  • @DekuVillano-n8h
    @DekuVillano-n8h 5 дней назад

    i was here (maybe a future pro scripter)

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

    But how can I make the color get back? i didnt get it sadly

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

      are you still stuck? if yes, i can help

  • @AndrewVella-r4j
    @AndrewVella-r4j 11 дней назад

    I was wondering if I could get another explanation of how the event using a function’s parameter works

  • @MR-VOXELATOR117
    @MR-VOXELATOR117 2 месяца назад +1

    Yessir:
    local TouchPart1 = game.Workspace.TouchPart
    local Colour = "White"
    TouchPart1.Touched:Connect(function(OtherPart)
    if Colour == "White" then
    TouchPart1.BrickColor = BrickColor.new("Dark red")
    task.wait(1)
    TouchPart1.BrickColor = BrickColor.new("Sand green")
    task.wait(1)
    TouchPart1.BrickColor = BrickColor.new("Earth green")
    task.wait(1)
    TouchPart1.BrickColor = BrickColor.new("Hot pink")
    task.wait(1)
    TouchPart1.BrickColor = BrickColor.new("Electric blue")
    task.wait(1)

    task.wait(4)
    print("cooldown done!")
    Colour = "White"
    end
    end)

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

    what kind of code"block" are "otherPart" and "player"? when i hover over them with the mouse, nothing shows up. pls help

  • @zanelixer
    @zanelixer 9 дней назад

    local touch = game.Workspace.touch
    local touched = false
    touch.Touched:Connect(function(otherPart)
    if not touched then
    touched = true
    print(otherPart.Name)
    -- Change color to a random color every time it's touched
    touch.Color = BrickColor.Random().Color
    -- Reset touched flag after a short delay
    task.wait(1)
    touched = false
    end
    end)

  • @samibeta-tv4ev
    @samibeta-tv4ev 2 месяца назад

    local touchPart = game.Workspace.Touchpart
    local partistouched = false
    touchPart.Touched:connect(function(otherpart)
    if partistouched == false then
    partistouched = true
    print("you have touched it")
    task.wait("10")
    partistouched = false
    end
    end)

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

    to change the colour of a part randomly when you touch it with a cooldown of 2 seconds:
    local Part = game.Workspace.Part
    local sphereTouched = false
    Part.Touched:Connect(function(thePart)
    if sphereTouched == false then
    sphereTouched = true
    Part.BrickColor = BrickColor.Random()

    task.wait(2)
    sphereTouched = false
    end
    end)

  • @AstroVlad
    @AstroVlad 3 дня назад

    local touch = game.Workspace.Part
    local touchingpart = false
    touch.Touched:Connect(function(otherpart)
    if touchingpart == false then
    touchingpart = true
    touch.Transparency = 0.9
    end
    wait(1)
    touch.Transparency = 0
    touchingpart = false
    end)
    This script is pretty cool cuz whenever i touch the part it makes it almost dissapear for 2 secs try it out :)

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

    i basically made an code that turns the part invisible and untouchable/uncollideable, and then after 5 seconds it turns visible again and touchable/collideable, and it doesnt turn invisible instantly, its bit by bit
    local touchPart = game.Workspace.TouchPart
    touchPart.Anchored = true
    touchPart.CanTouch = true
    touchPart.CanCollide = true
    touchPart.BrickColor = BrickColor.Red()
    touchPart.Transparency = 0
    touchPart.Touched:Connect(function(otherPart)
    touchPart.CanTouch = false
    for i = 0, 10, 1 do
    touchPart.Transparency = i/10
    task.wait(0.1)
    if i == 10 then
    touchPart.CanCollide = false
    task.wait(5)
    touchPart.Transparency = 0
    touchPart.CanCollide = true
    touchPart.CanTouch = true
    end
    end
    end)