Block animation not working on holding F

Making a block animation work on holding F, but it will stay at the block keyframe after the startup. To do this, I made a seperate animation that has the last keyframes of the other block animation but its looping at that one keyframe. The animation is not loading, this is in a local script. Block idle is the looping animation, block is the one with a startup.

local plr = game.Players.LocalPlayer
local bruh
local EZ
local LOL
local WOW
local inputservice = game:GetService("UserInputService")
local char = plr.Character or plr.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid")
local blockidle = Instance.new("Animation")
blockidle.AnimationId = "rbxassetid://5830357100"
local runtrack = humanoid:LoadAnimation(blockidle)
local block = Instance.new("Animation")
block.AnimationId = "rbxassetid://5829956934"
local runtrack2 = humanoid:LoadAnimation(block)
local function newanim()
	runtrack:Play()
end
local function onCharacterAdded(char)
	local hum = char:WaitForChild("Humanoid")
	bruh = humanoid:LoadAnimation(block)
	WOW = humanoid:LoadAnimation(blockidle)
local function inputended(input)
	if Enum.KeyCode == Enum.KeyCode.F then
		runtrack:Stop()
		runtrack2:Stop()
	end
		local function block()
			EZ = runtrack2:GetMarkerReachedSignal(block):Connect(newanim)
	LOL = inputservice.InputEnded:Connect(inputended)
	end
	local function inputBegan(input)
		if Enum.KeyCode == Enum.KeyCode.F and script.Parent.Parent.DuskSword.Equipped == true then
				block()
				runtrack2:Play()
				end
			plr.CharacterAdded:Connect(onCharacterAdded)
			inputservice.InputBegan:Connect(inputBegan)
		end
	end
end

1 Like

Why are attempting to char? Just get the player humanoid and load the animation and then play it. I also dont understand why you have made youre code so messy.

Iā€™m not sure how to fix it, could you show me how I would fix it? Would be appreciated thanks for the response

I am not sure about your issues but here are some tips:

No need to check if a variable is true unless its a text value. Replace script.Parent.Parent.DuskSword.Equipped == true with script.Parent.Parent.DuskSword.Equipped then.

Use more meaningful variables.

Use longer variables instead of just hum. Humanoid is much better. Then, instead of littering your variables at the top, make the function include the Instance.new statements and the load statements.