I'll get straight to the point. I was working on Server-Sided animations for my fps, and noticed that when I switch weapons, everything works fine until I switch back to my primary after switching to my secondary. The animation for the primary weapon, which I had then switched to from my secondary weapon, did not play and so the character was stuck with the idle animation of the secondary weapon but had the primary equipted. I'm not good at explaining things, so if you have questions, (which I'm sure you will,) I'll be answering them.
Framework script: (Local)
--wait until game is loaded
repeat wait() until game:IsLoaded()
--local variables
local plr = game.Players.LocalPlayer
local char = plr.Character
local cam = workspace.CurrentCamera
local mouse = plr:GetMouse()
local humanoid = char:WaitForChild("Humanoid")
--service variables
local runs = game:GetService("RunService")
local tweens = game:GetService("TweenService")
local uis = game:GetService("UserInputService")
local rs = game:GetService("ReplicatedStorage")
--misc variables
local modules = rs:WaitForChild("Modules")
local models = rs:WaitForChild("Models")
local running
local aiming
local secondaryEquipt = false
local primaryEquipt = true
local Keybinds = require(modules:WaitForChild("Keybinds"))
local ignore = Instance.new("Folder",workspace)
ignore.Name = "Ignore"
--CFrame variables
local maincf = CFrame.new()
local aimcf = CFrame.new()
local gunbobcf = CFrame.new()
--gun variables
local currentEquipt
local primary = "rifle"
local secondary = "pistol"
local currentData
local currentAnims
local currentIdolRemote
--remotes
local remotes = rs:WaitForChild("Remotes")
local CurrentRemotes
--debounce
local idleDebounce = false
--functions
function setup(gun)
currentEquipt = models:WaitForChild(gun):Clone()
currentEquipt.PrimaryPart = currentEquipt:WaitForChild("Handle")
currentEquipt.Parent = cam
currentData = require(modules:FindFirstChild(gun))
CurrentRemotes = remotes:FindFirstChild(gun)
maincf = currentData.maincf
for _,v in pairs(currentEquipt:GetChildren())do
if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("UnionOperation") then
if v.Anchored and not v.CanCollide then
else
v.Anchored = true
v.CanCollide = false
print("Fixed "..v.name..".")
end
if v:FindFirstChild("Weld") then
v.Weld:Destroy()
end
end
end
CurrentRemotes.IdleRemote:FireServer(CurrentRemotes.IdleRemote.Idle.Value)
end
function switch(target, replacement)
local removal
removal = cam:FindFirstChild(target)
removal:Destroy()
setup(replacement)
end
runs.RenderStepped:Connect(function()
if currentEquipt then
currentEquipt:SetPrimaryPartCFrame(
cam.CFrame
*maincf
*aimcf
*gunbobcf
)
end
if running then
gunbobcf = gunbobcf:Lerp(CFrame.new(
0.1* math.sin(tick()*6),
0.05 * math.sin(tick()*12),
0
),0.2)
end
if aiming then
aimcf = aimcf:Lerp(currentData.aimcf,0.2)
else
aimcf = aimcf:Lerp(CFrame.new(),0.1)
end
end)
uis.MouseIconEnabled = false
mouse.Button2Down:Connect(function()
aiming = true
end)
mouse.Button2Up:Connect(function()
aiming = false
end)
char.Humanoid.Running:Connect(function(speed)
if speed >= 0.1 then
running = true
else
running = false
end
end)
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Keybinds.Keybinds.secondary and secondaryEquipt == false then
switch(primary, secondary)
secondaryEquipt = true
primaryEquipt = false
elseif input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Keybinds.Keybinds.primary and primaryEquipt == false then
switch(secondary, primary)
secondaryEquipt = false
primaryEquipt = true
end
end)
setup(primary)

2 comments
Animations immediately replicate to the server. You don't need to do server-sided animations.
https://gyazo.com/5d2da8d1c03ee5de722f1434a540c5db