I made a script to animate several different NPC models using CollectionService. Each model has an IntVlaue called "ID" that holds the animation id that is to be played. Here is my code:
local CollectionService = game:GetService("CollectionService") local Tagged = CollectionService:GetTagged("Model") local Module = require(game.ServerStorage:WaitForChild("AnimateModels")) function animFunct(npc) local id = npc:WaitForChild("ID").Value Module.Animate(id,npc) end for _, npc in pairs(Tagged) do print(npc.Name) animFunct(npc) end CollectionService:GetInstanceAddedSignal("Model"):Connect(animFunct)
Despite there being two tagged models, the print statement only printed the name of one of them. In testing mode, one of the models was playing the animation while the other one was not. How do I get CollectionService to recognize my other tagged model?
I am using the plugin "Tag Editor" by Sweetheartichoke to tag my models, but when I tried manually tagging them through the script, the result was the same.