Issue with playing animations

Hello, Developers I’m trying to make a combat system with animation and a hitbox, but I don’t know what happened; the animations no longer work or play in my character.

local rp = game:GetService("ReplicatedStorage")
local remotes = rp:WaitForChild("Remotes")
local animations = rp:WaitForChild("Animations")
local Punch1 = animations.Combat.Punch1
local Punch2 = animations.Combat.Punch2
local Punch3 = animations.Combat.Punch3
local Punch4 = animations.Combat.Punch4

local punchRemote = remotes:WaitForChild("Punch")
local count = 0
local cooldown = 0.5

punchRemote.OnServerEvent:Connect(function(player)
	local character = player.Character
	local humanoid = character:WaitForChild("Humanoid")
	local Punch1Track = humanoid:LoadAnimation(Punch1)
	local Punch2Track = humanoid:LoadAnimation(Punch2)
	local Punch3Track = humanoid:LoadAnimation(Punch3)
	local Punch4Track = humanoid:LoadAnimation(Punch4)

	if count == 1 then
		count = nil
		Punch1Track:Play()
		task.wait(cooldown)
		count = 2
	elseif count == 2 then
		count = nil
		Punch2Track:Play()
		task.wait(cooldown)
		count = 3
	elseif count == 3 then
		count = nil
		Punch3Track:Play()
		task.wait(cooldown)
		count = 4
	elseif count == 4 then
		count = nil
		Punch1Track:Play()
		task.wait(cooldown)
		count = 1
	end

	local Hitbox = Instance.new("Part")
	Hitbox.Size = Vector3.new(5, 4, 5)
	Hitbox.Color = Color3.new(1, 0.25098, 0.25098)
	Hitbox.Transparency = 0.75
	Hitbox.Position = character.HumanoidRootPart.Position + character.HumanoidRootPart.CFrame.LookVector * 3
	Hitbox.Anchored = true
	Hitbox.CanCollide = false
	Hitbox.Parent = game.Workspace

	Hitbox.Touched:Connect(function(otherPart)
		local otherHumanoid = otherPart.Parent:FindFirstChildOfClass("Humanoid")
		if otherHumanoid and otherHumanoid ~= humanoid then
			otherHumanoid:TakeDamage(1)
		end
	end)

	wait(0.075)
	Hitbox:Destroy()
end)
1 Like

Try to use humanoid.Animator:LoadAnimation() instead of humanoid:LoadAnimation().

Does not work Idk what is the problem btw my character is R6

Is the animation priority Action or higher?

2 Likes

Never mid I fixed it thanks for help

1 Like

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