Animations not replicating to the server after player character is set manually

I want my character to be animated normally. I have a system where i take a character model from ReplicatedStorage and set its clone as the player’s character. I have found that the scripts in StarterCharacterScripts, as well as any default roblox character scripts (such as health, animate) are not replicated onto the player’s new character when i do this, so i decided to take the default roblox animate script and put it into the character model in ReplicatedStorage. This default script seems to work fine and with no errors locally, but when viewed from the server, animations from this script are not replicated to the server (even though this character model is the player’s character). I have tried giving network ownership of the character’s PrimaryPart to the player, and this has not worked. If anyone has a solution, or if i have to completely rewrite roblox’s default animation script with a tangled web of remoteEvents to have it animate on the server, i am all ears.

Character Spawning script:

game.ReplicatedStorage.ServerRemotes:WaitForChild("LoadCharacter").OnServerEvent:Connect(function(plr, char)
	if game.Workspace.TDM.CanSpawn.Value then
		local clone = char:Clone()
		clone.Name = plr.Name
		--plr:LoadCharacter()
		---local spawnPos = plr.Character.PrimaryPart.CFrame
		plr.Character = clone
		clone.Parent = game.Workspace
		clone.PrimaryPart:SetNetworkOwner(plr)
		
		local spawns =  game.Workspace.AsteroidMap.Spawns:GetChildren()
		local spawnLocation = spawns[math.random(1, #spawns)]
		
		clone:SetPrimaryPartCFrame(spawnLocation.CFrame + (spawnLocation.CFrame.UpVector * 4))
		
		wait()
		
		local ui = script.PlayerName:Clone()
		ui.Parent = plr.Character.Head
		ui.TEXT.Text = plr.Name
		ui.TEXT.TextColor3 = plr.TeamColor.Color
		ui.PlayerToHideFrom = plr
	end
end)

Video:

https://i.gyazo.com/4a3e1fe73c24f8713d645d39baf13730.mp4

I’m almost sure that, to fix this error, you just have to insert that same model into the StarterPlayer service and have it be named StarterCharacter. ROBLOX sets up the rest, as per written below. :slightly_smiling_face:

Additionally, you may add four objects to this service:

  • A StarterPlayerScripts instance, with scripts that run once for each player.
  • A StarterCharacterScripts instance, with scripts to add to each player’s character every time they spawn.
  • A Humanoid instance named StarterHumanoid , which will be used as the default humanoid for each player’s character.
  • A Model instance named StarterCharacter , which will be used as the character model for all players

https://developer.roblox.com/en-us/api-reference/class/StarterPlayer

1 Like

see, the thing is, i have a selection of characters that i need to load into the player when they respawn, depending on what they choose. As the starterCharacter system doesnt have a way to do this, i have to write my own system.

Hm. The problem would be that the “Animate” script is a local one. So, it only replicates on the client. An easier workaround than remote events, I guess, would be to animate the character with a server script so that it replicates to all clients without additional work. Not sure if that would slow the server.

1 Like

But why does the default roblox animate replicate to the server, even though it is a localScript?

And how would i get player inputs through a server script if the way you describe is the only way possible to do this?

As I see, you only set NetworkOwnership of PrimaryPart. Could you try changing every part’s networkownership to player instance and get back to me with result?

1 Like

I have given network ownership of every part of the player here, and the result is the same

https://i.gyazo.com/698da3b3dd2e4c70afb6cb4b487735cb.mp4

You might want to have a look into this thread.

Seems you’ll have to implement custom animation script for each player.

Edit
How are you activating the Animation script? Have you tried parenting it to player AFTER new character is made? So:

  1. Get the script from play solo.
  2. Deactivate the default script by creating a blank script in StarterCharacterScripts with the same name
  3. In your server spawning script do
AnimationScript:Clone().Parent = clone
1 Like

i will attempt this (however i dont need to put the blank animation script in, as none of roblox’s default scripts load into the character when they load in with my current system)

Said that just to make sure to prevent loading it before your custom rig script loads in.

1 Like

I have tried parenting the animation script to the character after the character is given to the player and parented to workspace. The animations still dont replicate ;-;

Will changing the StarterCharacter in StarterPlayer work during runtime? and if so, can i do it locally so that each player has their own character to be loaded in?

I’m not really sure about that. You should try giving it a shot.

LoadCharacter can only be called by the server. when called by the server, any client made starterCharacters will be non existent to the server, and so it will load the player’s avatar. For it to work this way (if you can even set the starterCharacter during runtime) is if everyone shared the same starterCharacter pool (which is really messy)

I guess what i could do is simply append my armor to one shared rig, but i feel like roblox should have a better system if a player wants to load their own character rather than everyone sharing the same StarterCharacter model, like maybe they could add a parameter to the Player:LoadCharacter() function which accepts an object value containing the character to be loaded.

I guess this isnt really a problem anymore, but this animation issue still has not been solved. I dont know whether i should mark a solution here.

What I meant by that would be to handle the animation processes on a server script and have a remote event connecting that to a local script that processes input. Kind of misworded myself there! :sweat_smile:

ROBLOX has its ways of doing it I guess.

I ended up using a single StarterCharacter and appending armor to the character. this seems to work fine.

https://i.gyazo.com/f1388b318ee578917aff4f015b141ad4.mp4

Thank you guys for your help!
.
.
*Still uncertain if i should mark a solution here btw

1 Like