I’ve been trying to make my own versatile system for food.
Recently I have came across a problem that has me stumped, the Tool.Activated seems to not work when referring to the Tag connected to it.
Here is the code:
local cs = game:GetService("CollectionService")
for _, part in pairs(cs:GetTagged("p")) do
part.Activated:Connect(function()
print("Hello")
end)
end
Nothing is coming into the Output, any help is MUCH appreciated.
Did you also connect to GetInstanceAddedSignal after looping on the tagged instance? Maybe the loop started and the tool hasn’t been loaded/tagged yet.
local TAG = "MyTagHere"
function OnAdded(tool : Tool)
tool.Activated:Connect(print)
end
for _, tool in CollectionService:GetTagged(TAG) do
task.spawn(OnAdded, tool )
end
CollectionService:GetInstanceAddedSignal(TAG):Connect(OnAdded)