STOP PUTTING SCRIPTS IN PARTS! | Roblox CollectionService Scripting Tutorial (2024)

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ต.ค. 2024
  • Caffeinate the team - www.buymeacoff...
    FOLLOW US ON TWITTER - / rbxvectorthree
    TAG EDITOR PLUGIN - www.roblox.com...
    In this tutorial, learn how to use CollectionService, a powerful tool that lets you tag objects to be selected by your script. This way, you don't have to put scripts in objects to have tons of parts doing the same behavior. This is super useful for making tons of kill bricks for your obby game, like Tower of Hell! Games like Pet Simulator X can tag coins as objects to be picked up so that they don't have to put the script in the coins!
    Join us on Roblox to play our upcoming games!
    www.roblox.com...
    Contact us:
    jake@vectorthree.dev

ความคิดเห็น • 149

  • @playDotProduct
    @playDotProduct  2 ปีที่แล้ว +12

    What tutorial would you like to see next?

    • @mahmoudabdulfattah7294
      @mahmoudabdulfattah7294 ปีที่แล้ว

      MarketplaceService please

    • @Sw1ffyEditz
      @Sw1ffyEditz 7 หลายเดือนก่อน

      Yoo pls instead of making the briks kill you with collection service make fade away bricks

  • @unique_gamer3728
    @unique_gamer3728 ปีที่แล้ว +48

    I feel so called out because I just made an obby with multiple parts named "KillBrick" with a script in each of them...

    • @stephen5070
      @stephen5070 3 หลายเดือนก่อน +5

      You can say you went a little over kill xD

    • @thebloodstonegamers9899
      @thebloodstonegamers9899 17 วันที่ผ่านมา

      8 year olds using dex explorer can easily delete those lol. It's a big mistake.

    • @guest_tristan55
      @guest_tristan55 11 วันที่ผ่านมา

      ​@@thebloodstonegamers9899 never let them know your next move: find the script in serverscriptservice

  • @co5tellooffical
    @co5tellooffical 2 ปีที่แล้ว +20

    How you only have 600 subs baffles me. Your content has been high quality since you started it. You should have way more.

    • @playDotProduct
      @playDotProduct  2 ปีที่แล้ว +1

      dont worry we'll be at 10k once we start posting consistently! i appreciate the kind words :)

    • @texterthesilly0
      @texterthesilly0 3 หลายเดือนก่อน +1

      @@playDotProduct you're at 7.91k! keep going!

    • @_DarkWolves
      @_DarkWolves 17 วันที่ผ่านมา

      Yuh

  • @rblxicy
    @rblxicy ปีที่แล้ว +12

    Best tutorial I have ever seen lol
    Short, Easy to hear, easy to understand
    I wish you had the 300k subs you deserve, but you definitely just earned +1!

    • @danielwomack8147
      @danielwomack8147 6 หลายเดือนก่อน

      What are you talking about "easy to understand"?

  • @DroideYT
    @DroideYT 9 หลายเดือนก่อน +3

    It's even better, you can create pause variables for each specific touch and manage the time as you wish, good service

  • @TheChickenYtRBX
    @TheChickenYtRBX 10 หลายเดือนก่อน +8

    Script: local Collect = game:GetService("CollectionService")
    for _, part in Collect:GetTagged("KillBrick") do
    part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
    hit.Parent.Humanoid.Health = 0
    end
    end)
    end

    • @ducanhkieu2564
      @ducanhkieu2564 9 หลายเดือนก่อน +1

      Thank you!

    • @BezinMaker
      @BezinMaker 8 หลายเดือนก่อน +1

      thanks

    • @HappyDudeOO5
      @HappyDudeOO5 6 หลายเดือนก่อน +1

      awesomesauce

    • @TheChickenYtRBX
      @TheChickenYtRBX 4 หลายเดือนก่อน +1

      5 months after I'm still helping!

    • @computerheadman1601
      @computerheadman1601 2 หลายเดือนก่อน +1

      thanks man

  • @dylanisaking
    @dylanisaking 9 หลายเดือนก่อน +1

    in my 2 years of roblox development i never knew how to use collectionservice, thanks alot!

  • @whitedeathproductions
    @whitedeathproductions ปีที่แล้ว +5

    I can see one problem with this is that if you'll have to use a wait() inside of the i,v loop, it will just delay the time until which the loop can reach following parts

    • @Darkman-ur7ob
      @Darkman-ur7ob ปีที่แล้ว +1

      i personally would just make it a courtine wrap

    • @kidgaming6529
      @kidgaming6529 ปีที่แล้ว

      @@Darkman-ur7ob ^

    • @simvoid4347
      @simvoid4347 ปีที่แล้ว

      why would you need to do that

    • @rc8s
      @rc8s ปีที่แล้ว +3

      You should not be using wait() in the first place

    • @onlyspectatormode
      @onlyspectatormode ปีที่แล้ว

      Why would you need a wait() in general when all the functionality you need can be tied in with the .Touched event?

  • @SplixCreates
    @SplixCreates 2 ปีที่แล้ว +4

    Thank you I had no idea how to collect my service before this.

  • @Gaazzee
    @Gaazzee 8 หลายเดือนก่อน

    Omg its been a whole year since the oof noise was changed... Time flies I guess its best we enjoy it.

  • @rtralph1269
    @rtralph1269 ปีที่แล้ว +3

    Okay so, what really confuses me is the for loops. I did see that you didn't clearly explain the for loop you used for the CollectionService thing.

  • @voiddestroyer6471
    @voiddestroyer6471 8 หลายเดือนก่อน

    TYSM THIS WILL SAVE ME A TON OF TIME FOR MAKING MULTIPLE BUTTONS IN MY UPGRADE TREE INSTEAD OF PUTTING A SCRIPT IN EACH ONE!

  • @KittDevv
    @KittDevv 2 ปีที่แล้ว +5

    Data store service tutorial or teleport service

  • @jessipeppermintz6372
    @jessipeppermintz6372 4 หลายเดือนก่อน +1

    OH MY GOD THANK YOUUuuuuu i've been trying to figure out how to make the color of a heart in the corner of the screen change depending on how much danger the player is in and i needed to know how to make one script for all dangerous objects instead of one for each individual dangerous object, THANK YOU!

  • @360sauce7
    @360sauce7 ปีที่แล้ว +2

    Thank you so much for this tutorial. I have a coin collection system with hundreds of coins around the map. I didnt know about this at the time, so I have a lot of editing to do.

  • @GoldKnight126
    @GoldKnight126 2 ปีที่แล้ว

    First comment! Also, nice video! I have no idea what the first steps are in Roblox game design but the video definitely seemed helpful to someone who does.

  • @oskiebadoskie
    @oskiebadoskie ปีที่แล้ว

    You're a super underrated youtuber and this is the best collectionservice video I've seen. Though, what do you use to edit? the transitions look great.

  • @Not0nce
    @Not0nce 7 หลายเดือนก่อน

    im so happy That I found this video. I was searching for so long for a video like this

  • @mr.sandwich2463
    @mr.sandwich2463 2 ปีที่แล้ว +3

    Haha I have small scripts that Clones the main kill script from ServerStorage into the killing part. So everytime I wanna change smt I just rewrite the script in server storage and we are ready to go

    • @playDotProduct
      @playDotProduct  2 ปีที่แล้ว +1

      You can do that, HOWEVER, as you grow in complexity with things you're doing that will give you issues. It's generally best to have one script. This kill part example is a super basic use case of tags, but the concepts apply to far more complex behaviors

  • @Input1080
    @Input1080 2 ปีที่แล้ว +4

    Thank you. Been waiting to look into on how collection service works foe the most part. Question: Why don't you just get children of a model or folder. Wouldn't that be easier?

    • @playDotProduct
      @playDotProduct  2 ปีที่แล้ว +3

      There are definitely instances in which you could do this! this helps if you have different groups of models that need to do the same thing however. Also, this is more to show how to use collectionservice which has tons of other use cases! Do what works best with your game :)

    • @xaviermeimei
      @xaviermeimei ปีที่แล้ว

      some of my collection parts are in different folders with special names essential to their functionality. in this case, a collection service is helpful because i can't have all part be in the same folder.

  • @CasterRational
    @CasterRational 2 หลายเดือนก่อน

    I sub ty for making vid u so good at editing :)

  • @EzWorkzzStudios
    @EzWorkzzStudios 6 หลายเดือนก่อน

    You blessed us with this amazing architecture technique. Thank you.

  • @dswqsa895
    @dswqsa895 7 หลายเดือนก่อน

    I learnt easily with this tutorial. Earned a sub!

  • @khaelou
    @khaelou ปีที่แล้ว +1

    Yet another great tutorial, I was so frustrated with the old method

  • @mrroasty99
    @mrroasty99 ปีที่แล้ว

    Thank u bro this was useful to not make my game very laggy make more vids like this

  • @HurricaneZerox
    @HurricaneZerox ปีที่แล้ว +3

    You are an actual superhero

  • @qIIxXxIIp
    @qIIxXxIIp ปีที่แล้ว

    I am very grateful to have found your video, it helped me a lot, since I was going to use many scripts, I really appreciate the help

  • @TheEGod.
    @TheEGod. 2 หลายเดือนก่อน

    0:12 i just use a module script lol
    but yeah this is really helpful! thanks!

  • @Noasuuu
    @Noasuuu ปีที่แล้ว +3

    Can i make this work for proximity prompts?

  • @dogeloafsquad-robloxgroup4164
    @dogeloafsquad-robloxgroup4164 ปีที่แล้ว

    I have just learnt something new and useful today, thank you!

  • @DedicatedScripter
    @DedicatedScripter ปีที่แล้ว

    Thanks! Gonna be very useful when I make more scripts for games.

  • @Usi.xl1
    @Usi.xl1 ปีที่แล้ว +1

    Very Helpful !

  • @X_INTENT
    @X_INTENT 9 หลายเดือนก่อน

    I miss the goofy "OUHGFF" noise. It was part of the fun 😭

  • @AnubitekOfficial
    @AnubitekOfficial ปีที่แล้ว +1

    You should include how to tag objects without the plugin.

  • @SophisticatedArc
    @SophisticatedArc 2 ปีที่แล้ว

    THANK YOU! I had like 50 parts and forgot to add scripts to them.

  • @whybotherwithusernames4880
    @whybotherwithusernames4880 ปีที่แล้ว +1

    i put a script into a part and it wont run, some help with that please?

  • @firtzz1
    @firtzz1 11 หลายเดือนก่อน +1

    This was very helpfull!

  • @blocc0
    @blocc0 2 หลายเดือนก่อน

    im so fucking confused because i usually make a folder in workspace named "DamageParts" or smth and every part in there will have like a value inside with the damage and will also be affected by a script that will check if any of them are touched and will give damage

  • @yuqiStudio
    @yuqiStudio หลายเดือนก่อน

    I wish I saw this sooner.... Great Video

  • @Jareltsai
    @Jareltsai ปีที่แล้ว +1

    why it didnt work?

  • @TheChickenYtRBX
    @TheChickenYtRBX ปีที่แล้ว +1

    cool my game was crashing every time but now with this new script life is better

  • @kerbiee6051
    @kerbiee6051 ปีที่แล้ว

    One way I do it is make a folder and put all the parts in the folder and I do a script

  • @vrajsavani
    @vrajsavani 2 ปีที่แล้ว +1

    had to like it cause it was that easy and simple.👍

  • @TStudio_Official
    @TStudio_Official 4 หลายเดือนก่อน

    The easy way is select all brick/lava and make them Union, and give the union just 1 script, it will be work

  • @tophatlord716
    @tophatlord716 5 หลายเดือนก่อน

    a problem i have with collection service
    i've made a looting system with collection service but if theres too many in workspace then it breaks and only one works

  • @SopkhimTwo
    @SopkhimTwo 2 ปีที่แล้ว

    Been doing this for a minute would recommend!

  • @mahmoudabdulfattah7294
    @mahmoudabdulfattah7294 ปีที่แล้ว

    amazing,please do you have video regarding to MarketplaceService

  • @amraam8723
    @amraam8723 ปีที่แล้ว +4

    @vectorthree Isn't it just easier to assign a value to a part and then loop trough the workspace for every part that has that value? It works well and when using multi threading i believe this is the best way

    • @plumpus1634
      @plumpus1634 ปีที่แล้ว +10

      thank you for describing what a tag is.

    • @Atzlk
      @Atzlk ปีที่แล้ว +2

      you could make a folder in workspace named "kill bricks" and have all your kill bricks inside of there, and look through that folder, so it dosent loop through the entire workspace

    • @plumpus1634
      @plumpus1634 ปีที่แล้ว

      @@Atzlk^

    • @Atzlk
      @Atzlk ปีที่แล้ว

      @@plumpus1634 just watched the video and understood how stupid the original comment is 😭

  • @LeapInno
    @LeapInno 9 หลายเดือนก่อน

    Really nice explanation.

  • @5nightsxxgaming463
    @5nightsxxgaming463 2 ปีที่แล้ว

    this was helpful, thanks!

  • @kilpamations3477
    @kilpamations3477 ปีที่แล้ว +1

    Does this work with clones?(by clones I mean scripted clones)

  • @unifores
    @unifores 7 หลายเดือนก่อน

    How to do this with many doors? Because I doubt I have to put everything inside an if...

  • @RealLava
    @RealLava ปีที่แล้ว

    or check if they are named KillBrick then kill if touched

  • @Propofol1234
    @Propofol1234 11 หลายเดือนก่อน

    Why can't you just make a folder of the parts and loop through the folder with a for loop instead of having to use the collection service

  • @Silly_Genius
    @Silly_Genius 8 หลายเดือนก่อน

    "Unable to cast value to Object" , I get this error in output. Please help

  • @giocido
    @giocido 9 หลายเดือนก่อน

    Or group all the kill bricks and create a script inside of that group...

  • @JoshieBoy_
    @JoshieBoy_ ปีที่แล้ว

    Couldn't you just use a loop through a table of killbricks

  • @dfsed1057
    @dfsed1057 ปีที่แล้ว

    Thanks for this vid -i'm implementing this now,but also wondering how I may use this service if I'm not just a Humanoid. For example, if I am driving a car or remote controlling a vehicle

  • @edward1234-cool
    @edward1234-cool 9 หลายเดือนก่อน

    Thank you, this really helps.

  • @GhostsJJK
    @GhostsJJK ปีที่แล้ว +1

    Or U can just make the kill parts a union and put the kill script in it

    • @playDotProduct
      @playDotProduct  ปีที่แล้ว +1

      Works on the surface level until you decide to do more complex things like maybe having one of the kill parts move

  • @axiompro123
    @axiompro123 6 หลายเดือนก่อน

    it doesnt work on local scripts pls help

  • @NathanHarris-l5c
    @NathanHarris-l5c 11 วันที่ผ่านมา

    Wait what happens if instead of a for loop you put it in a whole loop, does it make multiple touched events for each part or is there a limit, is there a way to remove the events later in the code and add them agian like if you wanted to change which parts kill and which don’t ?

  • @lobsclips
    @lobsclips ปีที่แล้ว

    this guy's voice is so nice

  • @-Timmy0604
    @-Timmy0604 ปีที่แล้ว

    For some reason, if I try copying the same part that's tagged, it'll pick a random part I copied and run the script on that part, not all of them. Any way to fix this?

  • @localxtop
    @localxtop ปีที่แล้ว

    Really good video W

  • @nas1373
    @nas1373 ปีที่แล้ว

    but what if you need to put that code into a module script?

  • @hlflifeenjoyer6176
    @hlflifeenjoyer6176 ปีที่แล้ว

    you just saved me 10 years of my life thanks bro

  • @chadou972oyaaa8
    @chadou972oyaaa8 8 หลายเดือนก่อน

    wtf where rhe scrip for copy

  • @ttcsalteregos
    @ttcsalteregos 9 หลายเดือนก่อน

    Can you use this for GUIs?

  • @noob_tom
    @noob_tom 8 หลายเดือนก่อน

    does anybody knows how to add tags to cloned object?

  • @baconheadhair6938
    @baconheadhair6938 11 หลายเดือนก่อน

    cant you just use for i,v loops?

  • @DagooseDev
    @DagooseDev ปีที่แล้ว

    When i do part on line 4 it says attempt to index nil with touched

    • @amraam8723
      @amraam8723 ปีที่แล้ว

      You wrote Touched correct?

  • @creeperplayzz
    @creeperplayzz 2 หลายเดือนก่อน

    Wow ty man!!

  • @smilingzculptor
    @smilingzculptor 7 หลายเดือนก่อน

    Idk i just use for i, v in pairs

  • @wonsole
    @wonsole 10 หลายเดือนก่อน +1

    Bro this is confusing me with the " for _ part in" part because it doesnt let me script and just fails and makes me type the entire thing instead with the part being red underlined

  • @FrankSodog
    @FrankSodog ปีที่แล้ว

    it work but it say Touched is not a valid member of Script

    • @rubenraidvere3294
      @rubenraidvere3294 ปีที่แล้ว

      it has to be part.Touched not script.parent.Touched

  • @OSFlames
    @OSFlames 6 หลายเดือนก่อน

    idk why but, The "CollectionService" Doesnt show up when i say "CollectionService" in the get service and same when i try tweenservice it just does "tweeninfo" Please i beg u please help

  • @pruzae
    @pruzae 2 ปีที่แล้ว

    Nice rebrand!

  • @Jing.TheKing
    @Jing.TheKing 7 หลายเดือนก่อน

    Can i do this for killing npcs that respawn? Cuz i have a script that spawns npcs by cloning them from serverstorage, so can i tag the npcs in server storage and do the same? Or will it not work

    • @dinfarmor
      @dinfarmor 7 หลายเดือนก่อน

      Yes if you change up the script a bit so that they are connected to the destroy function, debris or a loop.

  • @corners1733
    @corners1733 2 ปีที่แล้ว

    Practical and efficient, nice

  • @SwoopyTheGreat
    @SwoopyTheGreat ปีที่แล้ว

    can't you just put the parts in a folder and put a script

    • @KSAINMOST
      @KSAINMOST ปีที่แล้ว

      didnt work for me

    • @SwoopyTheGreat
      @SwoopyTheGreat ปีที่แล้ว

      Just what i thought you could do

    • @okay8151
      @okay8151 9 หลายเดือนก่อน +1

      that is also nice but this one is better

  • @smeggmann99
    @smeggmann99 2 ปีที่แล้ว

    Bro, you can just make a class with this kind of logic and assign each part that class

    • @playDotProduct
      @playDotProduct  2 ปีที่แล้ว +1

      Classes do have use as well! But if you wanted to assign the class to the parts- how would you select the parts? Tags :)

    • @LXT_RBLXDev
      @LXT_RBLXDev 2 ปีที่แล้ว

      ​@@playDotProduct You don't need to use tags to assign classes. All you have to do is iterate through objects, make sure their conditions are met (ex: Name == "KillBrick"), and just assign it.

    • @playDotProduct
      @playDotProduct  2 ปีที่แล้ว

      @@LXT_RBLXDev Yes- there are multiple solutions. But if they were in different locations it would be less performance intensive to tag items rather than looping through your entire game and checking conditions. And like I said, this tutorial is made to show how to use CollectionService, doesn't mean that it's the best solution for this particular instance.

    • @LXT_RBLXDev
      @LXT_RBLXDev 2 ปีที่แล้ว

      @@playDotProduct Are you sure it's less performance intensive? CollectionService is doing the same thing as I've explained it. I understand this video is to show how to use CollectionService, but I prefer iterating instead of using tags, the service takes extra steps and I find it more organized just iterating. You still have to manually select all the Killbricks of which you want to be tagged. That would be too much if you have over 1000 Killbricks. I think it's better to just iterate through workspace and assign a function into it. Just reset the events and reassign them for every new killbrick that gets added.

    • @bbnmm8720
      @bbnmm8720 10 หลายเดือนก่อน

      @@LXT_RBLXDev bro just use an folder or something why iterate through all workspace

  • @effortless4588
    @effortless4588 ปีที่แล้ว

    W informative channel

  • @TheEpikGamer
    @TheEpikGamer 2 ปีที่แล้ว

    but what if i do

  • @laser.strike
    @laser.strike 2 ปีที่แล้ว

    Subbed

  • @74L
    @74L 2 ปีที่แล้ว

    Just subscribed in case you come back to youtube and would you look at that

  • @AriannaICorreaG
    @AriannaICorreaG ปีที่แล้ว

    THANK YOUUU

  • @sleepylucky3224
    @sleepylucky3224 ปีที่แล้ว

    I love this tutorial

  • @Rand0_MGuY111
    @Rand0_MGuY111 7 หลายเดือนก่อน

    just group and add script /;

  • @matthewjorgenson4598
    @matthewjorgenson4598 ปีที่แล้ว

    great quality

  • @PapaaFN
    @PapaaFN 2 หลายเดือนก่อน

    Legend

  • @vreuny
    @vreuny 7 หลายเดือนก่อน

    nice

  • @ThisIsSendingMeProject
    @ThisIsSendingMeProject 5 หลายเดือนก่อน

    wow

  • @UnfortunateKera
    @UnfortunateKera ปีที่แล้ว

    Teach me haha

  • @AlreadyProYT
    @AlreadyProYT 2 ปีที่แล้ว

    wrong

  • @selfwastaken
    @selfwastaken ปีที่แล้ว

    i love you no homo