Taking out knife animation problem

so i’m trying to make a animation that when player pressed Q it will run an animation and will take out knife but sometimes the animation doesn’t fully load and it’s just makes it looks wired.
https://gyazo.com/aaff59455daeec9ff213de8b661a8994

here are the scripts

localscript:

game:GetService("UserInputService").InputBegan:Connect(function(key, prosseced)
	if prosseced then return end
	if key.UserInputType == Enum.UserInputType.Keyboard then
		
		
		if key.KeyCode == Enum.KeyCode.Q then
			game.ReplicatedStorage.Pressed.Qpressed:FireServer()
		end
		if key.KeyCode == Enum.KeyCode.LeftControl then
			game.ReplicatedStorage.Pressed.CtrlPressed:FireServer()
		end
		
		
	end
end)

script:

local debounce = true
game.ReplicatedStorage.Pressed.Qpressed.OnServerEvent:Connect(function(plr)
	local anim = Instance.new("Animation")
	anim.AnimationId = "rbxassetid://3778111135"
	local animtrak
	local character = plr.Character or plr.CharacterAdded:wait()
	local knife = character:FindFirstChild("Real")
	local HoldCopy = game.ServerStorage.CHARA.Hold.Real:Clone()
	local putndown = game.ServerStorage.CHARA.Putndown.Real:Clone()
	if debounce then
		debounce = false
		animtrak = character.Humanoid:LoadAnimation(anim)
		animtrak:Play()
		wait(animtrak.Length/2)
	if knife.Handle:FindFirstChild("LeftHipRigAttachment") then
		knife:Remove()
		character.Humanoid:AddAccessory(HoldCopy)
	else
		knife:Remove()
		character.Humanoid:AddAccessory(putndown)
	end
	anim:Remove()
	debounce = true
	end
end)

try adding a cooldown of maybe 0.5 second or 1 second before you set the debounce value back to true.
e.g

wait(1)
debounce = true
1 Like

Is there an actual problem with the animation or your code, or it just that sometimes (often the first time the animation is ran) it looks slightly strange? This isn’t quite something you can fix.

An attempt you can make to repair the animation is to pass it through to ContentProvider.PreloadAsync. This will make the asset get downloaded if it hasn’t been used before, so it should be readily available for immediate usage and thus get rid of the jittering.

i have no idea wheres the problem, but the animation just won’t load after sometime when you press Q, and it makes the knife just look like it teleports. and i can’t fix it can i atleast change the way i’m doing it so it would work?

how i use that? and do you mean using that will check if the animation asset is downloaded?

try to prioritize action for this animation in the animation editor