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
What tutorial would you like to see next?
MarketplaceService please
Yoo pls instead of making the briks kill you with collection service make fade away bricks
I feel so called out because I just made an obby with multiple parts named "KillBrick" with a script in each of them...
You can say you went a little over kill xD
8 year olds using dex explorer can easily delete those lol. It's a big mistake.
@@thebloodstonegamers9899 never let them know your next move: find the script in serverscriptservice
How you only have 600 subs baffles me. Your content has been high quality since you started it. You should have way more.
dont worry we'll be at 10k once we start posting consistently! i appreciate the kind words :)
@@playDotProduct you're at 7.91k! keep going!
Yuh
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!
What are you talking about "easy to understand"?
It's even better, you can create pause variables for each specific touch and manage the time as you wish, good service
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
Thank you!
thanks
awesomesauce
5 months after I'm still helping!
thanks man
in my 2 years of roblox development i never knew how to use collectionservice, thanks alot!
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
i personally would just make it a courtine wrap
@@Darkman-ur7ob ^
why would you need to do that
You should not be using wait() in the first place
Why would you need a wait() in general when all the functionality you need can be tied in with the .Touched event?
Thank you I had no idea how to collect my service before this.
lol
Omg its been a whole year since the oof noise was changed... Time flies I guess its best we enjoy it.
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.
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!
Data store service tutorial or teleport service
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!
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.
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.
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.
im so happy That I found this video. I was searching for so long for a video like this
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
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
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?
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 :)
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.
I sub ty for making vid u so good at editing :)
You blessed us with this amazing architecture technique. Thank you.
I learnt easily with this tutorial. Earned a sub!
Yet another great tutorial, I was so frustrated with the old method
Thank u bro this was useful to not make my game very laggy make more vids like this
You are an actual superhero
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
0:12 i just use a module script lol
but yeah this is really helpful! thanks!
Can i make this work for proximity prompts?
I have just learnt something new and useful today, thank you!
Thanks! Gonna be very useful when I make more scripts for games.
Very Helpful !
I miss the goofy "OUHGFF" noise. It was part of the fun 😭
You should include how to tag objects without the plugin.
module script
THANK YOU! I had like 50 parts and forgot to add scripts to them.
i put a script into a part and it wont run, some help with that please?
This was very helpfull!
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
I wish I saw this sooner.... Great Video
why it didnt work?
cool my game was crashing every time but now with this new script life is better
One way I do it is make a folder and put all the parts in the folder and I do a script
had to like it cause it was that easy and simple.👍
The easy way is select all brick/lava and make them Union, and give the union just 1 script, it will be work
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
Been doing this for a minute would recommend!
amazing,please do you have video regarding to MarketplaceService
@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
thank you for describing what a tag is.
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
@@Atzlk^
@@plumpus1634 just watched the video and understood how stupid the original comment is 😭
Really nice explanation.
this was helpful, thanks!
Does this work with clones?(by clones I mean scripted clones)
How to do this with many doors? Because I doubt I have to put everything inside an if...
or check if they are named KillBrick then kill if touched
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
"Unable to cast value to Object" , I get this error in output. Please help
Or group all the kill bricks and create a script inside of that group...
Couldn't you just use a loop through a table of killbricks
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
Thank you, this really helps.
Or U can just make the kill parts a union and put the kill script in it
Works on the surface level until you decide to do more complex things like maybe having one of the kill parts move
it doesnt work on local scripts pls help
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 ?
this guy's voice is so nice
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?
Really good video W
but what if you need to put that code into a module script?
you just saved me 10 years of my life thanks bro
wtf where rhe scrip for copy
Can you use this for GUIs?
does anybody knows how to add tags to cloned object?
cant you just use for i,v loops?
When i do part on line 4 it says attempt to index nil with touched
You wrote Touched correct?
Wow ty man!!
Idk i just use for i, v in pairs
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
thats because he put _, not _
it work but it say Touched is not a valid member of Script
it has to be part.Touched not script.parent.Touched
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
you have to have the plugin
@@CopperCrownDummyWhoMakesGames I had it
Nice rebrand!
Thank you :)
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
Yes if you change up the script a bit so that they are connected to the destroy function, debris or a loop.
Practical and efficient, nice
can't you just put the parts in a folder and put a script
didnt work for me
Just what i thought you could do
that is also nice but this one is better
Bro, you can just make a class with this kind of logic and assign each part that class
Classes do have use as well! But if you wanted to assign the class to the parts- how would you select the parts? Tags :)
@@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.
@@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.
@@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.
@@LXT_RBLXDev bro just use an folder or something why iterate through all workspace
W informative channel
but what if i do
:O
Subbed
Just subscribed in case you come back to youtube and would you look at that
THANK YOUUU
I love this tutorial
just group and add script /;
great quality
Legend
nice
wow
Teach me haha
wrong
wrong
wrong
i love you no homo