Animations not replicating to the server even though they're played from client?

Hello, I made a footplanting script and it works fine if I’m testing by myself in studio, but once I start a local server in studio it doesn’t replicate to the other clients. And there’s this odd issue that when I tab out and go back in, the animations don’t load anymore and they go back to the default animations. All of the animations are at “Idle” priority, one above the core animations so nothing should be overlapping them.

I tried moving the animation creation to the server and also adding :WaitForChild’s on the animation objects, but no luck.

Server script:

local footplantfold = script.Footplanting

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)		
		local folder = Instance.new("Folder")
		folder.Name = "Footplanting"
		
		for name, anim in pairs(footplantfold:GetChildren()) do
			local new = Instance.new("Animation", folder)
			new.Name = anim.Name
			new.AnimationId = anim.AnimationId
		end
		
		--print("Packaged.")
		
		folder.Parent = char
	end)
end)

Local script in StarterCharacterScripts:

local char = script.Parent
local Humanoid = char:WaitForChild("Humanoid")

local forward = false
local backward = false
local left = false
local right = false
local FootplantFold = script.Parent:WaitForChild("Footplanting")
local uis = game:GetService("UserInputService")


local frontanim = FootplantFold:WaitForChild("front")
local backanim = FootplantFold:WaitForChild("back")
local leftanim = FootplantFold:WaitForChild("left")
local rightanim = FootplantFold:WaitForChild("right")
local uprightanim = FootplantFold:WaitForChild("upright")
local upleftanim = FootplantFold:WaitForChild("upleft")
local downleftanim = FootplantFold:WaitForChild("downleft")
local downrightanim = FootplantFold:WaitForChild("downright")

local footplantanims = {
	front = Humanoid:LoadAnimation(frontanim),
	back = Humanoid:LoadAnimation(backanim),
	left = Humanoid:LoadAnimation(leftanim),
	right = Humanoid:LoadAnimation(rightanim),
	upright = Humanoid:LoadAnimation(uprightanim),
	upleft = Humanoid:LoadAnimation(upleftanim),
	downleft = Humanoid:LoadAnimation(downleftanim),
	downright = Humanoid:LoadAnimation(downrightanim),
}


for i, v in pairs(footplantanims) do
	v:AdjustWeight(0)
	
	if i == "right" or i == "downleft" or i == "downright" or i == "back" then
		v:Play(nil, nil, -1)
	else
		v:Play()
	end
end

function isolateanim(anim, weight)
	for i, v in pairs(footplantanims) do
		if i == anim then
			v:AdjustWeight(weight, 2)
		else
			v:AdjustWeight(0)
		end
	end
end

function setallweight(num, speed)
	for i, v in pairs(footplantanims) do
		v:AdjustWeight(num, speed)
	end
end

uis.InputBegan:Connect(function(key, gameProcessed)
	if not gameProcessed and key.UserInputType == Enum.UserInputType.Keyboard then
		if key.KeyCode == Enum.KeyCode.W or key.KeyCode == Enum.KeyCode.DPadUp then
			--print("forward")
			forward = true
		end	
		
		if key.KeyCode == Enum.KeyCode.A or key.KeyCode == Enum.KeyCode.DPadLeft then
			--print("left")
			left = true
		end	
		
		if key.KeyCode == Enum.KeyCode.D or key.KeyCode == Enum.KeyCode.DPadRight then
			--print("right")
			right = true
		end	
		
		if key.KeyCode == Enum.KeyCode.S or key.KeyCode == Enum.KeyCode.DPadDown then
			--print("backward")
			backward = true
		end	
	end
end)

uis.InputEnded:Connect(function(key, gameProcessed)
	if not gameProcessed and key.UserInputType == Enum.UserInputType.Keyboard then
		if not gameProcessed and key.UserInputType == Enum.UserInputType.Keyboard then
		if key.KeyCode == Enum.KeyCode.W or key.KeyCode == Enum.KeyCode.DPadUp then
			--print("forward")
			forward = false
		end	
		
		if key.KeyCode == Enum.KeyCode.A or key.KeyCode == Enum.KeyCode.DPadLeft then
			--print("left")
			left = false
		end	
		
		if key.KeyCode == Enum.KeyCode.D or key.KeyCode == Enum.KeyCode.DPadRight then
			--print("right")
			right = false
		end	
		
		if key.KeyCode == Enum.KeyCode.S or key.KeyCode == Enum.KeyCode.DPadDown then
			--print("backward")
			backward = false
		end	
	end
	end
end)

game:GetService("RunService").RenderStepped:Connect(function()
	local currentstate = Humanoid:GetState()
	
	if currentstate == Enum.HumanoidStateType.Jumping or currentstate == Enum.HumanoidStateType.Freefall then
		setallweight(0,.01)
	else
		if Humanoid.MoveDirection.Magnitude <= 0 then
			setallweight(0, .05)
		elseif forward then
			if left then
				isolateanim("upleft", 20)
			elseif right then
				isolateanim("upright", 20)
			else
				isolateanim("front", 20)
			end
		elseif backward then
			if left then
				isolateanim("downleft", 20)
			elseif right then
				isolateanim("downright", 20)
			else
				isolateanim("back", 20)
			end
		elseif left then
			isolateanim("left", 20)
		elseif right then
			isolateanim("right", 20)
		end	
	end
	
end)
2 Likes