Replacing default animation only plays for client

I am mistaken, animations are replicated across the server. Make sure your edited animation script is added to the character by the server, not the client.

So you’re saying I should change? Also It’s placed in StarterCharacterScripts.

Not sure what your asking for. Instead of using StarterCharacterScripts, try giving the character the animation script from a server script.

I’m asking if I should change it to a Server script. StarterCharacterScripts work fine.

Perhaps @CodeJared is referencing this previous forum post: How to change roblox default walking animation

For the record, I played around with this before and still had issues. From how frequently this question comes up and the discussions around it, everyone’s mileage varies.

Oh, I’ve already done that. All Animation Id changes are done on the server.

I had the same problem a year ago and I honestly forgot what I did to fix it. I think it had something to do with the server not recognizing the change in animation. Animations across the server-client boundary are a bit annoying and it isn’t documented well.

Well what I’m going to do is:

  1. Make all the clients update the animation id of every other player so that the client can see it because the problem is the client can’t see other player’s animations.

  2. Change the script to a server script to see if that may solve the issue

Hopefully I get some results.

EDIT: I’m gonna switch 2 and 1 around because 2 is simpler

#2 won’t work as changing it to a server sided script is going to cause a lot of problems. You’d be better off writing your own animation script at that point.

--[[
	
	Purpose of this script is to patch Roblox's stupid animate script for not replicating 
	the walk / run animation upon other clients. This will load it in the hard way on every
	character.

--]]

--|| SERVICES ||--
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--|| LOCAL ||--
local Pairs = pairs

--|| VARIABLES ||--
local Connections = {}

local function updateWalkAnimation(Player, Character)
	local Data = Player:WaitForChild("Data")
	local PlayerData = Data:WaitForChild("PlayerData")
	
	local Animate = Character:WaitForChild("Animate")

	local WalkAnimation = Animate.walk.WalkAnim
	local RunAnimation = Animate.run.RunAnim
	local IdleAnimation = Animate.idle.Animation1
	
	if PlayerData["Fighting Style"].Value ~= "" then
		WalkAnimation.AnimationId = ReplicatedStorage.Animations['Fighting Styles'][PlayerData["Fighting Style"].Value].Walk.Walk.AnimationId
		RunAnimation.AnimationId = ReplicatedStorage.Animations['Fighting Styles'][PlayerData["Fighting Style"].Value].Walk.Walk.AnimationId
		IdleAnimation.AnimationId = ReplicatedStorage.Animations["Fighting Styles"][PlayerData["Fighting Style"].Value].Idle.Idle.AnimationId
		
		print("[CUSTOM ANIMATION MANAGER]: "..Player.Name.."'s Custom Animations Has Been Updated.")
	else
		print("[CUSTOM ANIMATION MANAGER]: "..Player.Name.."'s Fighting Style Detected As Nil.")
	end
end

Players.PlayerAdded:Connect(function(Player)
	local Data = Player:WaitForChild("Data")
	local PlayerData = Data:WaitForChild("PlayerData")
	
	Connections[Player.Name] = {}
	
	Connections[Player.Name]["characterListener"] = Player.CharacterAdded:Connect(function(Character )
		updateWalkAnimation(Player, Character)
	end)
	
	Connections[Player.Name]["fsListener"] = PlayerData["Fighting Style"].Changed:Connect(function()
		local Character = Player.Character or Player.CharacterAdded:Wait()
		updateWalkAnimation(Player, Character)
	end)
end)

for _, Player in Pairs(Players:GetPlayers()) do	
	local Data = Player:WaitForChild("Data")
	local PlayerData = Data:WaitForChild("PlayerData")	
	
	local Character = Player.Character
		
	if Character then
		updateWalkAnimation(Player, Character)
	end
		
	Connections[Player.Name]["characterListener"] = Player.CharacterAdded:Connect(function(Character)
		updateWalkAnimation(Player, Character)
	end)
	
	Connections[Player.Name]["fsListener"] = PlayerData["Fighting Style"].Changed:Connect(function()
		Character = Player.Character or Player.CharacterAdded:Wait()
		updateWalkAnimation(Player, Character)
	end)
end

Players.PlayerRemoving:Connect(function(Player)
	local connectionCount = 0
	for username, connections in Pairs(Connections) do
		if username == Player.Name then
			for _, connection in Pairs(connections) do
				connectionCount = connectionCount + 1
				connection:Disconnect()
			end
		end
	end
	
	print("[CUSTOM ANIMATION MANAGER]: Cleared up "..connectionCount.." connections!")
end)

print("[CUSTOM ANIMATION MANAGER]: CUSTOM ANIMATION MANAGER HAS BEEN LOADED.")

So I attempted to basically update it for all the clients but it seems like that’s not a solution. Honestly I have no clue anymore

By placing a script in StarterCharacterScripts, the server is automatically doing the heavy lifting by cloning its contents into the character during the character spawning procedure.

Between making a manual distribution script and using StarterCharacterScripts, there is no difference other than the purpose of the latter being to add character scripts in the first place and the former being unnecessary work for something provided natively.

1 Like

@Mystifine, I fixed this bug by only changing the run animation to the new animation.

I don’t know how this fixed it or why changing the ‘walk’ animation with the ‘run’ animation broke it but yeah…

Were other players able to see your walk animation in live servers? Also which id did you change in the script?

The ‘run’ animation in the ‘animNames’ table

The walk animation is only used for mobile when the player drags the thumbstick a little way’s distance from the original position. The walk and run animation blend depending on how far the player drags the thumbstick. For computer, only the run animation is used.

That would be why changing the run animation gets it down for you but changing the walk animation doesn’t. :slight_smile:

Yea but that still doesn’t explain why changing both the walk and run animation to the desired id breaks the run animation. The only reason I could think of is that if the run and walk animation are the same id they both try to use the same animation (because same id) and that somehow breaks it

It wasn’t intended to explain: it was a comment on the use of the walk animation.

Considering the blending behaviour of the walk and run animations, it is unexpected (and probably unintended as well) for both of those animations to be the same, as they never usually are. Playing two of the same animation and blending them is probably producing this unexpected result.

I do find the behaviour a little curious though and I feel like looking into it on my own time. For the sake of clarification: you only changed the run animation and this got rid of any problems for you in regards to changing animations?

Yea I only changed the run animation which got rid of all the issues

1 Like

For future reference: playing two AnimationTracks which are of the same animation object asset ID at the same time results in buggy playback when their weights are blended together.

This is the most likely cause of breaking animations by modifying the default Animation script, typically due to the Walk and Run animation being set to the same asset ID. The Animation script will try to play and blend both of these animation tracks at the same time, but since they’re the same asset id, replication is buggy.

In the future you can test whether animations are actually being replicated properly by enabling in Studio: File > Settings > Network > Show Active Animation Asset. Within Studio, this will show all the animations playing for each humanoid/Animator object along with diagnostic data (animation weight etc). This helps you rule out potential problems because you can see how an animation is playing on a different client.

Sadly this is one of many grievances involved with using Roblox’s animation system for blending animations (we gain convenience, but we pay in weird bugs).

For PC it looks like the walk animation still plays at walkspeed of 16, but the weight is set to 0.00.

Note that this doesn’t just apply to the Animate script. I personally discovered this issue when I was trying to make some directional movement animations, but didn’t bother to make different assets for each direction. Never play multiple animations with the same ID at the same time, playback will be ruined on other clients.

13 Likes

Thanks! I tried this and it worked for me too