I don’t think this is supposed to go in Scripting Support, But I have a question.
In what I’m making I use a ClientReplication system to handle VFX, Animation, and what not. But I have no idea how to handle animation on dummies. Do I animate them on the server?
Or…
Do I have to fire the Animation Replication to all clients. Or can I just simply Animate it on a single client and it will automatically replicate like normal?
Hi! About animations: if you need to play animation on dummy (not player), you need to call animation in server script to play animation on all clients.
Script:
print("Called!");
local humanoid = script.Parent.Humanoid;
local anim = script.Parent.Animation;
local animTrack = humanoid.Animator:LoadAnimation(anim);
-- Or old Version: humanoid:LoadAnimation();
animTrack:Play();
After this there will be a message in the console: “Called!”. And Animation would be played.
If paste this code in LocalScript (in StarterCharacterScripts folder), we recieve this message and animation but only in current client. (other players and server dont see this animation)
print("Called!");
local humanoid = workspace.Rig.Humanoid;
local anim = workspace.Rig.Animation;
local animTrack = humanoid.Animator:LoadAnimation(anim);
-- Or old Version: humanoid:LoadAnimation();
animTrack:Play();
You have to animate NPC’s on the server since the changes need to replicate to all clients for them to see it (NPC in server space). While you can fire a remote event to all clients, I do not recommend this as the server won’t see the animation being played on the NPC (you can still do it)
local NPC = workspace.NPC
local animation = NPC.Humanoid.Animation
local animtrack = NPC.Humanoid.Animator:LoadAnimation(animation)
animtrack:Play()
—-[[\Or you can do this instead\]]
game.ReplicatedStorage.AnimationEvent:FireAllClients(animation)
—-Then you can load and play it on the client
game.ReplicatedStorage.AnimationEvent.OnClientEvent:Connect(function(an)
local animtrack = workspace.NPC.Humanoid.Animator:LoadAnimation(an)
animtrack:Play()
end)