Potential collection service tool problem

So the other day I was testing around with the idea of not putting anything in tools when I thought of the idea of using collection service to handle a certain subset of tools. So I went to work on the script… and it didn’t work. Any help would be useful since I really don’t want to fall back to my older system

local CollectionService = game:GetService(“CollectionService”)

for i, v : Tool in pairs(CollectionService:GetTagged(“Melee”)) do

v.Activated:Connect(function()
	print("wow")
end)

v.Equipped:Connect(function()
	print("wow")
end)

end

Bumping this since i don’t really see anyone talk about this

1 Like

all I could do is remove unnecessary things but essentially does the exact same thing

local cs = game:GetService("CollectionService")
local meleeweapons = cs:GetTagged("Melee")

for _, melee in pairs(meleeweapons) do
melee.Activated:Connect(function()
print("wow")
end)

melee.Equipped:Connect(function()
print("wow")
end)
end
1 Like

I don’t think using CollectionService for something like this is a good idea. I would suggest working with ModuleScripts instead so tools with similar functionalities can use the same library of functions.

3 Likes

The thing is tho is that the tools I’m making are going to have a predefined list of things to do (M1,Heavy attack etc). My whole idea is that when i activate these tools i can fire the server with the tools name and from there i can use a module script to handle the variations in abilities. Its not like the tools I’m using are going to be varied at all

1 Like

How exactly does this script work when it comes to Tagging?

If you Attempt to get the Tagged Objects prior to tagging an object, nothing will appear as there is nothing tagged.

I used tag editor to tag objects prior to getting the tagged objects in game.

1 Like

you can enable tag editing in properties via beta features

im not saying dont use tag editor
just a recommendation for convenience

1 Like

oh alright, ill do that right now

2 Likes