Animations not playing

Hello, I’ve been following a tutorial on Youtube

This:

I’ve follow it clearly especially the code

Server:

local RemoteEvent = game.ReplicatedStorage.ExecuteCombat

RemoteEvent.OnServerEvent:Connect(function(client, data)
	if data.Action == "m1" then
		data.Target.Humanoid:TakeDamage(20)
		if data.Air == "Up" then
			local bp = Instance.new("BodyPosition")
			bp.Position = data.Character.PrimaryPart.Position + Vector3.new(0,30,0)
			bp.P = 1200
			bp.MaxForce = Vector3.new(99999,99999,99999)
			bp.D = 200
			bp.Name = "Position"
			bp.Parent = data.Character.PrimaryPart
			game.Debris:AddItem(bp, 1)
			
			local bp = Instance.new("BodyPosition")
			bp.Position = data.Target.PrimaryPart.Position + Vector3.new(0,30,0)
			bp.P = 1200
			bp.MaxForce = Vector3.new(99999,99999,99999)
			bp.D = 200
			bp.Name = "Position"
			bp.Parent = data.Target.PrimaryPart
			game.Debris:AddItem(bp, 1)
		elseif data.Air == "Down" then
			for i,v in pairs(data.Target.PrimaryPart:GetChildren()) do
				if v:IsA("BodyMover") then
					v:Destroy()
				end
			end
			local bv = Instance.new("BodyVelocity", data.Target.PrimaryPart)
			bv.Velocity = (data.Character.PrimaryPart.CFrame.LookVector * 1 - Vector3.new(0,2,0)) * 25
			bv.MaxForce = Vector3.new(99999,99999,99999)
			bv.Name = "Velocity"
			game.Debris:AddItem(bv, .2)
		elseif data.Combo == 5 then
			local bv = Instance.new("BodyVelocity", data.Target.PrimaryPart)
			bv.Velocity = data.Character.PrimaryPart.CFrame.LookVector * 75
			bv.MaxForce = Vector3.new(99999,99999,99999)
			bv.Name = "Velocity"
			game.Debris:AddItem(bv, .2)
				
		else
			local bv = Instance.new("BodyVelocity", data.Target.PrimaryPart)
			bv.Velocity = data.Character.PrimaryPart.CFrame.LookVector * 10
			bv.MaxForce = Vector3.new(99999,99999,99999)
			bv.Name = "Velocity"
			game.Debris:AddItem(bv, .2)
			local bv = Instance.new("BodyVelocity", data.Target.PrimaryPart)
			bv.Velocity = data.Character.PrimaryPart.CFrame.LookVector * 75
			bv.MaxForce = Vector3.new(99999,99999,99999)
			bv.Name = "Velocity"
			game.Debris:AddItem(bv, .2)
		end
	end
end)

Client:

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

local UserInputService = game:GetService("UserInputService")

local RemoteEvent = game.ReplicatedStorage.ExecuteCombat

local lastTimeM1 = 0
local lastM1End = 0
local combo = 1

local CanAir = true

local punchAnims = {
	'rbxassetid://9094407109',           
	"rbxassetid//9094468704",             
	"rbxassetid//9094472126",             
	"rbxassetid//9094477222",             
	"rbxassetid//9094487105"              
}

local airAnims = {
	'rbxassetid://10251483276',
	'rbxassetid://10251486100',
}

local function hb(size, cFrame, ignore, char)
	local hb = Instance.new("Part", workspace.FX)
	hb.Anchored = true
	hb.CanCollide = true
	hb.Transparency = .6
	hb.Name = "hb"
	hb.Material = Enum.Material.ForceField
	hb.CanQuery = false
	hb.Size = size
	hb.CFrame = cFrame
	
	local con
	con = hb.Touched:Connect(function()
		con:Disconnect()
	end)
	
	local lasttarg
	
	for i,v in pairs(hb:GetTouchingParts()) do
		if v.Parent:FindFirstChild("Humanoid") and table.find(ignore, v.Parent) == nil then
			if lasttarg then
				if (lasttarg.Position - char.PrimaryPart.Position).Magnitude > (v.Position - char.PrimaryPart.Position).Magnitude then
					lasttarg = v.Parent.PrimaryPart
				end
			else
				lasttarg = v.Parent.PrimaryPart
			end
		end
	end
	
	hb:Destroy()
	if lasttarg then
		return lasttarg.Parent
	else
		return nil
	end
end

UserInputService.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 and tick() - lastTimeM1 > .3 and tick() - lastM1End > .7 then
		if tick() - lastM1End > .7 then
			combo = 1
		end
		
		lastTimeM1 = tick()
		
		local Animation = Instance.new("Animation", workspace.FX)
		local air = nil
		
		if UserInputService:IsKeyDown("Space") and combo == 4 and CanAir then
			CanAir = false
			Animation.AnimationId = airAnims[1]
			air = "Up"
		elseif not UserInputService:IsKeyDown("Space") and combo == 5 and not CanAir then
			Animation.AnimationId = airAnims[2]
			air = "Down"
		else
			Animation.AnimationId = punchAnims[combo]
		end
		
		local load = humanoid:LoadAnimation(Animation)
		load:Play()
		
		Animation:Destroy()
		
		local hitTarg = hb(Vector3.new(4,6,4), character.PrimaryPart.CFrame * CFrame.new(0,0,-3), {character}, character)
		
		if  hitTarg then
			local data = {
				["Target"] = hitTarg,
				["Character"] = character,
				["Combo"] = combo,
				["Air"] = air,
				["Action"] = "m1",
			}
			
			RemoteEvent:FireServer(data)
		end
		
		if combo == #punchAnims then
			combo = 1
			lastM1End = tick()
		else
			combo += 1
		end
		humanoid.WalkSpeed = 0
		wait(.4)
		humanoid.WalkSpeed = 18
	end
end)

humanoid.StateChanged:Connect(function(old, new)
	if new == Enum.HumanoidStateType.Landed then
		CanAir = true
	end
end)

UserInputService.JumpRequest:Connect(function()
	if tick() - lastTimeM1 < 1 then
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	else
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)

	end
end)

IT WOULD BE HIGHLY APPRECIATED IF YOU HELP ME FIX THIS PROBLEM:)

Did you search for your problem?

Yeah, I did. I followed it, I asked for my friends help, But he’s offline

I’m sorry, I can’t because I’m not a programmer. I only know a little.

1 Like