Animating npcs on the client

  1. What do you want to achieve?
    I want to load NPC animations on the client.

  2. What is the issue?
    I am conflicted over how to do this.

  3. What solutions have you tried so far?
    I did look for solutions, and found some, but they never explained the method to doing this.
    I tried cloning the local script for animating player characters, then parent it to a folder dedicated to npc animations. I set it up so that it will play animations for that specific npc. It doesn’t work however. A problem I also have is that I am using StreamingEnabled, so if npcs aren’t in the range, the animate script won’t get parented properly, and when the player does encounter that npc, the npc won’t have animations.

Feel free to call out any mistakes in my post, as I am new to the devforum.
I appreciate some help.

Well for what i think, you will have to specify the npc in the local script and then do a :LoadAnimation in the local script to the npc and when u want the animation to be played just make some function that plays the animation depending on what you want. (Im not sure if this gonna work this is what i think from my experience with local and server side scripts)

Edit: If you dont know how to play the animation make it work with .OnServerEvent with an event remote in replicatedstorage and make the server side script do :FireServer to that remote, If you dont have a script that loads the animation try to make a script in the starterplayerscripts and make the :LoadAnimation like this for example

local anim ="Animation")
anim.AnimationId = "rbxassetid://ID"
local animL = NPC.humanoid:LoadAnimation(anim)

--and to play the animation from a server side event like this
local remote = game.ReplicatedStorage.Remote
--if the animation plays in the local scirpt then u dont need a remote

Im trying to implement roblox’s Animate script which is used for players so it doesn’t feel like npcs and players live in different worlds. I appreciate you taking your time to try and help though.

You can play test your game and then go to your character model and copy the Animate script. After that, you would simply be able to take the animations ids and then use them for your NPCs.