Adding knockback to my M1 combat system

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I have an M1 combat system for my fighting game, and I want knockback on the final, fourth M1.

  2. What is the issue? Most of the attempts I’ve tried so far aren’t working with my system, I’ve looked at a couple tutorials now and they haven’t yielded any results, so I’m asking for help here.

here is the following code I’m using as my M1 system, any suggestions and ideas would be a massive help.

local bindableFunction = script:WaitForChild("Function")

local rs = game:GetService("ReplicatedStorage")
local rsAnimationsFolder = rs:WaitForChild("Animations")

local plrs = game:GetService("Players")
local lp = plrs.LocalPlayer
local char = lp.Character or lp.CharacterAppearanceLoaded:Wait()
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")

local hitremote = game.ReplicatedStorage.HitVFX

local m1sPerformed = 0

local currentM1 = 0

local m1Debounce = false

local comboEndCooldown = 1



local waitBeforeReset = 0.5

local damageScript = script:WaitForChild("Damage")
local damageRF = damageScript:WaitForChild("RemoteFunction")

bindableFunction.OnInvoke = function()

	if not m1Debounce then

		m1Debounce = true

		m1sPerformed += 1
		currentM1 += 1

		local correspondingM1anim = rsAnimationsFolder:FindFirstChild("M1 ("..currentM1..")")

		local m1Track = animator:LoadAnimation(correspondingM1anim)

		m1Track:GetMarkerReachedSignal("Hit"):Connect(function()

			local hitboxCFrame = char:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0, 0, -4)
			local hitboxSize = Vector3.new(3, 3, 3)

			local createHitbox = workspace:GetPartBoundsInBox(hitboxCFrame, hitboxSize)

			local humsHit = {}

			for i, v in pairs(createHitbox) do

				if v.Parent:FindFirstChild("Humanoid") and not humsHit[v.Parent.Name] and v.Parent ~= char then

					humsHit[v.Parent.Name] = true

					-- What you want it to happed once it hits the opponent

					damageRF:InvokeServer(v.Parent, 2)
					
					script.hit_punch_l:Play()
					

				end

			end

		end)

		m1Track:Play()

		task.wait(m1Track.Length - 0.1)

		task.spawn(function()

			local oldM1sPerformed = m1sPerformed

			task.wait(waitBeforeReset)

			if oldM1sPerformed == m1sPerformed then

				currentM1 = 0

			end

		end)

		if currentM1 == 4 then
			
			hum.WalkSpeed = 5

			task.wait(comboEndCooldown)

			hum.WalkSpeed = 16

			currentM1 = 0
	    end

		m1Debounce = false

	end

end
4 Likes

Use AssemblyLinearVelocity it ia a Vector3 value which apply force according to it is value and it goes over time so it should be a great way to make knock back

2 Likes

I am aware of this, and I’ve tried implementing it into my script, only for it to fail.
I’m right now attempting to figure out how to make a RemoteEvent, as I suspect AssemblyLinearVelocity doesn’t work in Local scripts, which is what my M1 system is built in.

2 Likes