i feel so dumb knowing that the hours i spent copying and pasting scripts was a huge waste of time. This is going to make everything easier thank you so much!
Lol I didn't even know collectionservice was a thing. I just created object classes and pretty much built my collection service. This makes it so much easier.
You'd be surprised how much this helped with something entirely unrelated. kinda unrelated I wanted to make it so when you click a button, it did something, but there were a ton of buttons. I first tried a for loop, but apparently when you click it runs as many times as there are buttons, which is really buggy. I didn't want to manually type a bunch of code for each button, so this helped a lot, thanks!
I had this Problem where I needed to copy and paste the same script into a ton of tools just to make it so you cant walk over em and pick them up and now I just tag a tool and Boom! It`s Great
Hey it probably made you interested, and that was the whole point. I find learning scripting with an example instead of abstract concepts is a lot easier.
@@BRicey yeah, the “scripters” who watch TheDevKing only learn this to get rich off of a simulator. Chads like us learn to become extremely well rounded programmers.
For some reason, on line 3 for "Script", the line "local connections {}" gives me an error (red squiggly line) underneath the first curly bracket and I'm just confused why? Even the use of the word "connections" on line 18 also gives me an error too. Code: local CollectionService = game:GetService("CollectionService") local connections {} local function makeLandmine(part) local connection = part.Touched:Connect(function(hit) local character = hit:FindFirstAncestorWhichIsA("Model") if character then local humanoid = character:FindFirstChild("Humanoid") if humanoid then local explosion = Instance.new("Explosion") explosion.Position = part.Position explosion.Parent = workspace part:Destroy() end end end) connections[part] = connection end for _, landmine in pairs(CollectionService:GetTagged("Landmine")) do makeLandmine(landmine) end CollectionService:GetInstanceAddedSignal("Landmine"):Connect(function(instance) makeLandmine(instance) end) CollectionService:GetInstanceRemovedSignal("Landmine"):Connect(function(instance) if connections[instance] then connections[instance]:Disconnect() end end)
Wow. My method would be to have a single script in all like objects that would just clone The script they were going to use from server storage then delete the script that setup the clone. This way when i wanted to update all those models, i just change one code.
brother, from the videos I see you have a lot of experience with roblox studio, if I may ask how long have you been using roblox studio? however you are great! and never give up with roblox studio
Whenever I Tag an instance inside the player GUI, for whatever reason it doubles the index length of the returned #Array. Can anybody explain why this is happening to me? I tried using differently named Tags and I get the same results.
Before watching this I used to put 1 part in server storage with the kill script n then copy it into the workspace during runtime but tagging is better lol 😂
I understand how to go about this with functions and script connections, but what about while loops? How would I implement collection service on while loops
is there a possible way to use this detection with custom characters? Ive got tagged models that the player becomes which they stay tagged but when a player touches the tagged player, it doesn't seem to detect it
Very good explained but sometimes hard for me due to my industry knowledge. Table? Huh? Your making a connection dictionary. But very good explanations, I can get in to scripting fast now.
How would you add a local variable which is different for every mine ? I tried using this to add a lot fading platforms that disapear for 10 seconds when I touch them, but I wasn't able to use a local boolean to say if it is already touched. I had to use and Attribute on each platform and update it in the function
on line 18 connection has a blue line local CollectionService = game:GetService("CollectionService") local connections = {} local function makeLandmine(part) part.Touched:Connect(function(hit) local character = hit:FindFirstAncestorWhichIsA("Model") if character then local humanoid = character:FindFirstChild("Humanoid") if humanoid then local explosion = Instance.new("Explosion") explosion.Position = part.Position explosion.Parent = workspace part:Destroy() end end end) connections[part] = connection -- here end for _, landmine in pairs(CollectionService:GetTagged("Landmine")) do makeLandmine(landmine) end CollectionService:GetInstanceAddedSignal("Landmine"):Connect(function(instance) makeLandmine(instance) end) CollectionService:GetInstanceRemovedSignal("Landmine"):Connect(function(instance) if connections[Instance] then connections[Instance]:Disconnect() end end)
local CollectionService = game:GetService("CollectionService") local test = workspace.Test --here wait(5) CollectionService:AddTag(test, "Landmine") wait(5) CollectionService:RemoveTag(test, "Landmine")
Idk if my computer's just broken or smth but it doesn't let me tag the part, when i use the tag thingy this box comes up next to the words and doesn't let me properly do it it'd be real helpful if you could explain what's wrong cause I just wanna make a good game n publish it:(
I think since the video has been released, the tag editor was updated, and now you have to click that box, its a check box, when its checked it means a part is tagged.
tagging isnt required. you can just loop through the entire game and add whatever you need to if it exists: ---------- for _, v in pairs(game:GetDescendants()) do
-----
local function Main(InstanceItem) -- You can also insert any parameters you'd like.
-- Do whatever
end
-----
local TargetedItemName = 'Part' -- Name of the item your targeting. Set it to nil if you dont want to search by name. local TargetedItemClass = 'Part' -- Part, Script, LocalScript, Sound, FloorWire, etc. Set it to nil if you dont want to search by class.
-----
if TargetedItemName == nil and v.ClassName == TargetedItemClass then
Main(v)
elseif TargetedItemClass == nil and v.Name == TargetedItemName then
Main(v)
elseif v.Name == TargetedItemName and v.ClassName == TargetedItemClass then
Looping through game descendants requires a lot of computing power, especially players with not-so-optimal computers (or phones) which is the majority of the ROBLOX platform. Also, tagging allows you to target groups of parts with different names and is a lot easier to read anyway. While it's not needed, it's much more readable and flexible.
i feel so dumb knowing that the hours i spent copying and pasting scripts was a huge waste of time. This is going to make everything easier thank you so much!
Keep grinding bro your content is very much appreciated
Lol I didn't even know collectionservice was a thing. I just created object classes and pretty much built my collection service. This makes it so much easier.
can u show me something about ur class
how did you create your classes?
@@ooo8188Object Oriented Programming with Modules
You'd be surprised how much this helped with something entirely unrelated.
kinda unrelated
I wanted to make it so when you click a button, it did something, but there were a ton of buttons. I first tried a for loop, but apparently when you click it runs as many times as there are buttons, which is really buggy. I didn't want to manually type a bunch of code for each button, so this helped a lot, thanks!
Man, you need to keep this up, you saved my life today with this vid!
Best Roblox Studio youtuber on the platform
I had this Problem where I needed to copy and paste the same script into a ton of tools just to make it so you cant walk over em and pick them up and now I just tag a tool and Boom! It`s Great
You could also turn off “CanTouch” under the properties tab of the tool or it’s handle
@@X_Infinity8 but that will make it that nothing can touch it
@@stefotheguy2766 That’s CanCollide not CanTouch, CanTouch makes it so it can’t be picked up
@@X_Infinity8 OH thats smart I thougth it was two way system it cant touch and it cant be touched I'll be doing that for my game then thanks :D
I don't comment often but this was really helpful with collectathon systems, I wish learned about tags sooner
I think ur one of the best scripters out there!
Thank you!
i wasn't ready for "So lets say you are building a landmine" 🤣
Hey it probably made you interested, and that was the whole point. I find learning scripting with an example instead of abstract concepts is a lot easier.
@@BRicey how did you learn to script?
You had me at landmine
high quality video 👍 needed this for knit
Ya that knit game tutorial was super helpful, glad you could use my video to help you out!
this is very useful, im subbing man
commiting war crimes with the bois (great tutorial dude)
Thank you, it was clear
Honestly, why do you have so little views and subs when you explain it so well?
Because there are so little people thst want to learn in depth. The cool thing is, as time goes on, more people will get curious and join.
@@BRicey Hopefully.
@@BRicey this is true my dog actually joined in.
@@BRicey yeah, the “scripters” who watch TheDevKing only learn this to get rich off of a simulator. Chads like us learn to become extremely well rounded programmers.
For some reason, on line 3 for "Script", the line "local connections {}" gives me an error (red squiggly line) underneath the first curly bracket and I'm just confused why?
Even the use of the word "connections" on line 18 also gives me an error too.
Code:
local CollectionService = game:GetService("CollectionService")
local connections {}
local function makeLandmine(part)
local connection = part.Touched:Connect(function(hit)
local character = hit:FindFirstAncestorWhichIsA("Model")
if character then
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
local explosion = Instance.new("Explosion")
explosion.Position = part.Position
explosion.Parent = workspace
part:Destroy()
end
end
end)
connections[part] = connection
end
for _, landmine in pairs(CollectionService:GetTagged("Landmine")) do
makeLandmine(landmine)
end
CollectionService:GetInstanceAddedSignal("Landmine"):Connect(function(instance)
makeLandmine(instance)
end)
CollectionService:GetInstanceRemovedSignal("Landmine"):Connect(function(instance)
if connections[instance] then
connections[instance]:Disconnect()
end
end)
because it needs to be "local connections = {}"
spitting actual facts though @@chris_beingstupid
Love you dad
U too son
Wow. My method would be to have a single script in all like objects that would just clone The script they were going to use from server storage then delete the script that setup the clone.
This way when i wanted to update all those models, i just change one code.
That's one way of doing it. It's not wrong, but I feel like collection service would be easier.
by that i mean you can select multiple units by holding left click selction and then once they are selected they will pathfind to the cursors location
very specific...
I tried this but the problem was like one of the parts were transported from the replicatedStorage into the workspace but still, it does not work.
I was wondering why my game's servers were so slow
brother, from the videos I see you have a lot of experience with roblox studio, if I may ask how long have you been using roblox studio?
however you are great!
and never give up with roblox studio
Smart, I just put what in a folder and run a loop getting folder children. Although tagging is better
I mean that works too
Could you make a tutorial on how to do dropdown menus i rlly need it thx
so ive been watching stuff and i cant find what i need can you do a tutorial how to make warcraft 3 type units and selection
Whenever I Tag an instance inside the player GUI, for whatever reason it doubles the index length of the returned #Array.
Can anybody explain why this is happening to me? I tried using differently named Tags and I get the same results.
I love after the years of development and watching tutorials everyone says dot like game.players everyone says dot
Before watching this I used to put 1 part in server storage with the kill script n then copy it into the workspace during runtime but tagging is better lol 😂
How to make "SoldierFriend" team tag?
Or just use Modules
B Ricey
is this possible with models instead with parts?
I understand how to go about this with functions and script connections, but what about while loops? How would I implement collection service on while loops
nevermind coroutines
is there a possible way to use this detection with custom characters? Ive got tagged models that the player becomes which they stay tagged but when a player touches the tagged player, it doesn't seem to detect it
Maybe the touch is the problem, not the tags.
The plugin is unavailable tho D:
Damn I was just making a folder and using for I,v in pairs()
How to you get all this knowledge from?
Very good explained but sometimes hard for me due to my industry knowledge. Table? Huh? Your making a connection dictionary. But very good explanations, I can get in to scripting fast now.
Yea Luau is kinda whacky when it comes to industry standards... it even uses 1-indexing instead of 0
How would you add a local variable which is different for every mine ? I tried using this to add a lot fading platforms that disapear for 10 seconds when I touch them, but I wasn't able to use a local boolean to say if it is already touched. I had to use and Attribute on each platform and update it in the function
use set attribute
on line 18 connection has a blue line local CollectionService = game:GetService("CollectionService")
local connections = {}
local function makeLandmine(part)
part.Touched:Connect(function(hit)
local character = hit:FindFirstAncestorWhichIsA("Model")
if character then
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
local explosion = Instance.new("Explosion")
explosion.Position = part.Position
explosion.Parent = workspace
part:Destroy()
end
end
end)
connections[part] = connection -- here
end
for _, landmine in pairs(CollectionService:GetTagged("Landmine")) do
makeLandmine(landmine)
end
CollectionService:GetInstanceAddedSignal("Landmine"):Connect(function(instance)
makeLandmine(instance)
end)
CollectionService:GetInstanceRemovedSignal("Landmine"):Connect(function(instance)
if connections[Instance] then
connections[Instance]:Disconnect()
end
end)
and this too
local CollectionService = game:GetService("CollectionService")
local test = workspace.Test --here
wait(5)
CollectionService:AddTag(test, "Landmine")
wait(5)
CollectionService:RemoveTag(test, "Landmine")
I cant test the game
Couldn’t you use tables to accomplish this? What makes this a better method?
Yes I think using tables woul be easier but I would like to know what makes it a better method
You are using tables, collection service gives u a table of all of the things tagged.
Idk if my computer's just broken or smth but it doesn't let me tag the part, when i use the tag thingy this box comes up next to the words and doesn't let me properly do it it'd be real helpful if you could explain what's wrong cause I just wanna make a good game n publish it:(
I think since the video has been released, the tag editor was updated, and now you have to click that box, its a check box, when its checked it means a part is tagged.
Not working
tagging isnt required. you can just loop through the entire game and add whatever you need to if it exists:
----------
for _, v in pairs(game:GetDescendants()) do
-----
local function Main(InstanceItem) -- You can also insert any parameters you'd like.
-- Do whatever
end
-----
local TargetedItemName = 'Part' -- Name of the item your targeting. Set it to nil if you dont want to search by name.
local TargetedItemClass = 'Part' -- Part, Script, LocalScript, Sound, FloorWire, etc. Set it to nil if you dont want to search by class.
-----
if TargetedItemName == nil and v.ClassName == TargetedItemClass then
Main(v)
elseif TargetedItemClass == nil and v.Name == TargetedItemName then
Main(v)
elseif v.Name == TargetedItemName and v.ClassName == TargetedItemClass then
Main(v)
end
-----
end
Looping through game descendants requires a lot of computing power, especially players with not-so-optimal computers (or phones) which is the majority of the ROBLOX platform.
Also, tagging allows you to target groups of parts with different names and is a lot easier to read anyway. While it's not needed, it's much more readable and flexible.
Plus you don't get the cool dynamic collection service functions such as "GetInstanceAddedSignal" or "GetInstanceRemovedSignal"
Thanks
Paul Joseph Watson
first
first
couldnt u just do this with a modulescript
Can you make a tutorial on how to make a rocket (body velocity )