Player animation looks awful but looks fine on dummies

I’m making a system that allows a player to slide, however the animation behind the system does not work well on players (whether idle or moving). I’ve tried: Changing animation priority, changing animation weight, changing animations, playing animation on server and on client.

local Crosshair = require(script.DynamicCrosshair).New(script.Parent.CrosshairContainer,10,18)
Crosshair:Enable()

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local weaponsManager = require(ReplicatedStorage.Libraries.WeaponsManager)

local UIS = game:GetService("UserInputService")

local mouseDown = false
local isCrouching = false

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

local isSliding = false

local humanoid : Humanoid = char:FindFirstChild("Humanoid")

local slideTrack = char:FindFirstChild("Animator",true):LoadAnimation(game.ReplicatedStorage.Effects.SharedAnims.Slide)
slideTrack.Priority = Enum.AnimationPriority.Action

local slideDuration = 1
local slideSpeed = 50

local function startSlide()
	if isSliding or humanoid:GetState() ~= Enum.HumanoidStateType.Running then
		return
	end
	isSliding = true
	slideTrack:Play()
	char.Humanoid:SetAttribute("sliding",true)
	game.ReplicatedStorage.Remotes.SlideStateUpdate:FireServer(true)
	local bodyVelocity = Instance.new("BodyVelocity")
	bodyVelocity.Velocity = char.HumanoidRootPart.CFrame.LookVector * slideSpeed
	bodyVelocity.MaxForce = Vector3.new(100000, 0, 100000)
	bodyVelocity.Parent = char.HumanoidRootPart

	local listener = humanoid.Jumping:Once(function(active)
		if active then
			bodyVelocity:Destroy()
			isSliding = false
			char.Animate.AnimatorFrozen.Value = false
			slideTrack:Stop()
			game.ReplicatedStorage.Remotes.SlideStateUpdate:FireServer(false)
			char.Humanoid:SetAttribute("sliding",false)
		end
	end)

	task.delay(slideDuration, function()
		if isSliding then
			listener:Disconnect()
			bodyVelocity:Destroy()
			isSliding = false
			slideTrack:Stop()
			game.ReplicatedStorage.Remotes.SlideStateUpdate:FireServer(false)
			char.Humanoid:SetAttribute("sliding",false)
		end
	end)
end

local isSprinting = false

UIS.InputBegan:Connect(function(input,proc)
	
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		-- code not needed for post		
	end
	
	if input.KeyCode == Enum.KeyCode.LeftShift then
		isSprinting = true
	end
	
	if input.KeyCode == Enum.KeyCode.R then
		weaponsManager:requestReload()
	end
	
	if input.KeyCode == Enum.KeyCode.LeftControl or input.KeyCode == Enum.KeyCode.C  then
		print(isSprinting)
		if humanoid.MoveDirection ~= Vector3.zero and isSprinting and not isSliding and not isCrouching then
			startSlide()
		else
			if isSliding then
				return
			end
			isCrouching = not isCrouching
			weaponsManager.crouch(isCrouching)
		end
	end
end)
-- some code is removed as it isnt relevant to the issue (probably)

-- server handling
Remotes.SlideStateUpdate.OnServerEvent:Connect(function(plr,isSliding)
	for i,v in pairs(plr.Character:FindFirstChild("Animator",true):GetPlayingAnimationTracks()) do
		v:Stop()
	end
	local playerAnimations = existsInAnimationList(plr.Character)
	if playerAnimations then
		playerAnimations.animations.idle:Play()
	end
	plr.Character.Humanoid.HipHeight = if isSliding then 1 else 2
end)

If I’m missing anything or more context is needed let me know.

Forgot to add the clips, they are attached here.

Expected animation:


Current behavior:

try setting the animation priority to a higher priority, looks like it’s pretty low

1 Like

try setting it to action, I think by default it set the priority to idle

1 Like

The priority was tested being set to Action and Action4 which still gave me the same results.

1 Like

Try setting animation weight to a high number, might help

1 Like

No luck. I tried both:

slideTrack:Play()
slideTrack:AdjustWeight(10000) -- also tried setting it to math.huge
slideTrack:AdjustWeight(10000) -- also tried setting it to math.huge
slideTrack:Play()

The issue was an incompatibility with the Roblox Weapon Kit’s Shoulder Camera Module. Specifically line 495-497 of the ShoulderCamera module.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.