Default Animations Interference

I’m trying to make a custom sprint and dash animation but the default animations are overlapping with my custom animations. I have already tried setting the animation priority to action both in studio and in the animation editor. Neither of those fixed my problem. I also tried setting the animation weight really high and that also did not help. I have already checked for other solutions on the dev forum but none of the solutions worked for me and also many of them are still unresolved.

Here is an example of what is happening
https://gyazo.com/66e39d6c2ebe959ec04162c7d18de3f3

This is my sprint script

local player = game.Players.LocalPlayer
local character = script.Parent
local humanoid = character.Humanoid
local animator = humanoid.Animator
local animation = game.ReplicatedStorage.Animation.Sprint
local animTrack = animator:LoadAnimation(animation)

local fx = game.ReplicatedStorage.Fx

local WALKSPEED = 16
local RUNSPEED = 40

local lastRun = 0
local direction = 1
local lastPosition = character.PrimaryPart.Position

local uis = game:GetService("UserInputService")
local ts = game:GetService("TweenService")
local rs = game:GetService("RunService")

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Whitelist
params.FilterDescendantsInstances = {workspace.Map}

uis.InputBegan:Connect(function(input, gpe)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		humanoid.WalkSpeed = RUNSPEED
		animTrack:Play()
		
	end
end)

uis.InputEnded:Connect(function(input, gpe)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		humanoid.WalkSpeed = WALKSPEED
		animTrack:Stop()
	end
end)

rs.Heartbeat:Connect((function()
	if (character.PrimaryPart.Velocity * Vector3.new(1,0,1)).Magnitude > WALKSPEED * 2 and humanoid.FloorMaterial ~= Enum.Material.Air then
		if tick() - lastRun > 6/RUNSPEED then
			lastRun = tick()
			
			local step =  fx.Dust:Clone()
			step.Parent = workspace.Fx
			step.CFrame = character.PrimaryPart.CFrame * CFrame.new(direction,-3,0)
			local rayResult = workspace:Raycast(step.Position + Vector3.new(0,1,0), Vector3.new(0,-3,0), params)
			if rayResult then
				step.Attachment:WaitForChild("Dust").Color = ColorSequence.new{
					ColorSequenceKeypoint.new(0, rayResult.Instance.Color),
					ColorSequenceKeypoint.new(1, rayResult.Instance.Color)
				}
			end 
			step.Attachment.Dust:Emit(10)
			game.Debris:AddItem(step, 1)
			direction = direction * -1
		end
		for i = 1, math.random(1,3) do
			local hb = Instance.new("Part", workspace.Fx)
			hb.Anchored = true
			hb.CanCollide = false
			hb.Transparency = .8
			hb.Name = "hb"
			hb.Material = Enum.Material.SmoothPlastic
			hb.CanQuery = false
			hb.Size = Vector3.new(.07,.07,math.random(4,6))
			local colorRand = math.random(1,3)
			if  colorRand == 1 then
				hb.Color = Color3.fromRGB(0,0,0)
			else
				hb.Color = Color3.fromRGB(180,180,180)
			end
			local dirCframe = CFrame.new(lastPosition, character.PrimaryPart.Position)
			hb.CFrame = dirCframe * CFrame.new(math.random(-25,25)/10,math.random(-3,3), math.random(-2,2))
			game.Debris:AddItem(hb,.2)
			ts:Create(hb,TweenInfo.new(.2),{Transparency = 1, Size = Vector3.new(0,0,0), CFrame = hb.CFrame * CFrame.new(0,0,math.random(2,4))}):Play()
		end
	else
		direction = 1
	end
	lastPosition = character.PrimaryPart.Position
end))

And this is my dash script

local player = game.Players.LocalPlayer
local character = script.Parent
local humanoid = character.Humanoid
local animator = humanoid.Animator

local animation = game.ReplicatedStorage.Animation
local anim = animation.Dash
local animTrack = animator:LoadAnimation(anim)
animTrack.Priority = Enum.AnimationPriority.Action

--debounce for the dash
local DASHING = false

--constants
local WALKSPEED = 16
local DASHSPEED = 100

--services
local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")

uis.InputBegan:Connect(function(input, gpe)
	if input.KeyCode == Enum.KeyCode.Q and DASHING == false then
		DASHING = true
		animTrack:play()
		humanoid.WalkSpeed = DASHSPEED
		wait(.2)
		animTrack:Stop()
		if uis:IsKeyDown(Enum.KeyCode.LeftShift) then
			humanoid.WalkSpeed = 40
		else
			humanoid.WalkSpeed = WALKSPEED
		end
		wait(.2)
		DASHING = false
	end
end)

Thanks for any help you can give a new dev!

Set the animation’s Priority to something like Action, so it overrides all animations.
Edit: I had realized you already tried that so this is no longer relevant.

I have already tried setting the animation priority to action both in the script and in the animation editor.

The default animate script still loads the animations to the humanoid, not the Animator. Maybe try editing the default animate script so it loads the animations to the humanoid’s Animator.

I’m pretty sure that anytime you load an animation to humanoid, It automatically creates an Animator if one doesn’t exist.

Humanoid:LoadAnimation() is what the default animate script uses. It is deprecated and loads animations onto the Humanoid.

I found this: Animator | Roblox Creator Documentation
it says,

“It is created when Humanoid:LoadAnimation() or AnimationController:LoadAnimation() is called under a Humanoid or AnimationController for the first time.”

You could try stopping the default animations in the default Animate script when an attribute/value is set to true by your dashing & sprinting script. Might be a bit hard to do, but, it’s the only way I can think of if setting the priority or weight doesn’t work.

Also, use the task library’s task.wait over wait, more performant.

1 Like

That does seem like a bit of a hassle but I’ll keep it in mind. Also thanks for the tip about task.wait! I’ll be using that from now on.

1 Like

I have also tried leaving no empty keyframes in the custom animation just in case, the default animations are able to show through during those frames. Needless to say, that still didn’t work.