Character Animations only playing on Client after changing Character Model

I’m having this issue where the animations are only playing locally, and not replicating to the server after replacing the character’s model with another model that is stored in ServerStorage, with a Animation script inside it already.
image

This is my code:

  	local char = Info.Characters[character]
  	local model = char.Skins[skin].Model:Clone()
  	local playerChar = player.Character
  	
  	model.Name = player.Name
  	player.Character = model
  	
  	model.Parent = workspace
  	playerChar:Destroy()

I’m so confused to why it’s happening, i’ve tried a bunch of fixes on the devforum, and none of them worked.

1 Like

u have to playerChar = model
char barrage

playerChar is a variable to store the original character so I can delete it after I set the new player model, so I don’t think that’s correct

i myself have made many character changing scripts tht is correct

its not just a variable tht u set player.Character is a path for the player model and modules to uk find the char do they keybindings movement camera,etc.

okay, but when i get the variable player.Character, I am getting the existing character as player.Character returns the character model; I already set player.Character to model; the issue im having is getting the idle animation, walk, etc to replicate from client to server.

bro is the character even moving cuz u have to set game.Players.LocalPlayer.Character to the current character

  1. you cannot call LocalPlayer from a server script…
  2. The character moves, and it even gives me the model and I can move any everything, animations even work, but only show for the client, and not for the server.

yIpK6CaIq1

ok ok lemme get this for the char changing so what i do is make a localscript with uis fire a remote event when a key or ui button is pressed and then the server has

re.OnServerEvent:Connect(function(plrmodel)
local newchar = char.Skins[skin].Model:Clone()
newchar.Name = player.Name
plrmodel.Character:Destroy()
newchar.Parent = game.Workspace
plrmodel.Character = newchar

end)

edit: if u did something else could u pls explain it

1 Like

The answer is easy see your image there, the script called animate is a local script which is meant for doing things on the client side while on the other hand a server script is for doing things on the server side however but you can change model or properties using a local script. on the other hand we have a server script which is for doing things on the server side and what is done in the server is visible to everyone like your animation for example. So you must input that code into a server script called animate and replace the local script animate with the server script.

Hope this helps :smiley:

1 Like

I have actually tried this, but it has an issue where it’ll play the animations too late due to server lag, which is why a LocalScript is used to do this in the first place [an if I don’t replace the character, the LocalScript replicates the animations to the server.]

ok keep your local script but only keep one variable in the local script called

local LocalPlayer = game:GetService("Players").LocalPlayer

after this you must use a server script and enter the code into that script

I did same thing, and for me animations work on server side too, no idea what’s the issue

That’s why I’m so confused at all of this, lol.

I believe all that would need to be done is to load one of the Character’s animations from a script on the Server so that an Animator object is created. I utilized the solution from the thread referenced below after creating a Custom Character tutorial video, which allowed for animations to replicate properly:

1 Like

Thank you so much, that worked!

1 Like

Are you running that code in the post in a local or server script?

Edit: Nvm the post is solved

1 Like