Hi,
I made a working tag service but the problem is that when you clone an object with a tag, there is no function in it. How do I make it so that when an object is cloned with a tag on it, I can add the function to it?
Here’s my tag service:
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Packages = ReplicatedStorage.Packages
local AllTags = script:GetChildren()
local Knit = require(Packages.Knit)
local TagService = Knit.CreateService{
Name = "TagService",
Client = {}
}
for _, TagModule in pairs(AllTags) do
if not TagModule:IsA("ModuleScript") then
continue
end
local Module = require(TagModule)
if not Module then
warn("something is wrong with ".. TagModule.Name, "Module")
end
if not Module.Tag then
warn(TagModule.Name.. " tagmodule doesn't contain tag string.")
return
end
if not (type(Module) == "table") and (type(Module["Function"]) == "function") then
warn(TagModule.Name.. " tagmodule doesn't contain function.")
return
end
for _, part in pairs(CollectionService:GetTagged(Module.Tag)) do
Module.Function(part)
end
end
CollectionService.TagAdded:Connect(function(tag: string)
print("does not work on cloned objects @devforum")
end)
return TagService