hello. im struggling to decide how i should be implementing default animations (walking, running, jumping, …) for my game’s NPCs.
i cant just paste ROBLOX’s Animate script onto them because some NPCs will be created during runtime, and from what i remember, LocalScripts dont run in workspace.
for a past project of mine, what i did was adapt the Animate script code into a function, giving me the ability to sort of bypass that localscript limitation. however, i feel that is a unreliable hacky way of going about it and probably subject to issues later down the line.
should i be writing my own animation controllers or is there an easier way of doing this?
yes, but thats not the issue. i want the NPC to automatically play animations depending on the actions it does (sort of like the player, like when you jump itll play the jump animation, etc etc)
if i remember correctly you can get the status of a humanoid, maybe you could play an animation depending on their status? I feel as if there’s a better way of doing this though…
you can, but thatd be jumping into the realm of writing a custom system… ROBLOX already offers a script that does this for us (its why im hesitating on creating my own), but i cant get it to work properly for characters created during runtime
I also do not remember ROBLOX’s Animate script being local? And I’m pretty sure if local scripts are put into workspace during gameplay then they run. I could just be lying but I wish I could help.
I think making your own system for animations could be easier if you fail with anything else easier.
You could use a remote function and call the function with a parameter of which animation to play. local remoteFunction = game.ReplicatedStorage.AnimationFunction
remoteFunction:InvokeServer(“walk”)
You can also use a remote event and on the client side you call it like: local remoteEvent = game.ReplicatedStorage.AnimationEvent
remoteEvent:FireServer(“walk”)
Then on the server side you check for the parameter and play the animation accordingly.