I’ve made this post before, but the method I received only works with animations I own.
Is there any way I can use the new ROBLOX animations (e.g. the fortnite dances) in NPCs? I am just trying to get the animation ids.
Yes you can use the insert service along with the npc like this:
--server script
local insertService = game:GetService("InsertService")
local npc = -- put npc here
local animationId = --put animation Id here
local success,animModel = pcall(function()
return insertService:LoadAsset(animationId)--must be wrapped in a pcall as this function can error
end)
local animationTrack,animation
if success then
animModel.Parent = workspace
--this is necessary becuz the insert service returns the animation track in a model
for _,child in pairs(animModel:GetChildren())do
animationTrack = child
end
animation = npc:WaitForChild("Humanoid"):LoadAnimation(animationTrack)
--this will play the animation forever and create a new thread so any proceeding lines of code would execute
coroutine.wrap(function()
while true do
animation:Play()
animation.Stopped:Wait()
end
end)()
end
**warning there may be some syntax errors i did this online
2 Likes