here is what I have so far
local NPC = game.Workspace.NPC local function AnimationFunction() if NPC:FindFirstChild("StatueAnimation") then local animation = NPC:WaitForChild('StatueAnimation') local humanoid = NPC:WaitForChild('Humanoid') local StatueAnimation = humanoid:LoadAnimation(animation) StatueAnimation:Play() print("exampleanimation played") elseif NPC:FindFirstChild("ExampleAnimation") then local animation = NPC:WaitForChild('ExampleAnimation') local humanoid = NPC:WaitForChild('Humanoid') local ExampleAnimation = humanoid:LoadAnimation(animation) ExampleAnimation:Play() print("exampleanimation played") else print("not working") end end for k,n in pairs(game.Workspace:GetChildren()) do if n.Name == "NPC" then AnimationFunction() end end
im PRETTY SURE this will work. If it doesnt, im sorry.
local function AnimationFunction(NPC) if NPC:FindFirstChild("StatueAnimation") then local animation = NPC:WaitForChild('StatueAnimation') local humanoid = NPC:WaitForChild('Humanoid') local StatueAnimation = humanoid:LoadAnimation(animation) StatueAnimation:Play() print("exampleanimation played") elseif NPC:FindFirstChild("ExampleAnimation") then local animation = NPC:WaitForChild('ExampleAnimation') local humanoid = NPC:WaitForChild('Humanoid') local ExampleAnimation = humanoid:LoadAnimation(animation) ExampleAnimation:Play() print("exampleanimation played") else warn("not working") end end for k,n in pairs(game.Workspace:GetChildren()) do if n.Name == "NPC" then AnimationFunction(n) end end
also sorry for horrid formatting