Basically, I am trying to lerp the player that I am hitting 10 studs on the Z-Axis corresponding to my player's CFrame. The moving part works perfectly fine however, the player that I am hittings body rotates to the same orientation as my character. How would I go about fixing this? I am not using a bodymover for this situation due to friction/inconsistent forces. I am determined to only use CFrame lerping for this script. I have tried to incorporate LookVector, but I can't seem to find a way. I'm pretty bad with CFrame so please mind my ignorance if this is an easy question, and all help is appreciated!

Here is a gif of the problem: http://gyazo.com/8895b2e7090de094b650227c822042eb

--Part of Module that is needed
	function damage:KnockBack(v, stunanim, kbfr, kbdr)
		self.StunAnim = stunanim
		self.KnockbackForce = kbfr
		self.KnockbackDir = kbdr
			
		local stunt = v:FindFirstChild("Humanoid"):LoadAnimation(self.StunAnim)
		stunt:Play()
		stunt:AdjustSpeed(3)	
			
		for i = 0,self.KnockbackForce, 0.1 do
			v:FindFirstChild("HumanoidRootPart").CFrame = v:FindFirstChild("HumanoidRootPart").CFrame:lerp(self.KnockbackDir, i)
			print(i,v)
			wait()
			end	
	end

--ServerScript
damage = require(game.ServerScriptService:WaitForChild("damagemodule"))
 
game.ReplicatedStorage:WaitForChild("testre").OnServerEvent:Connect(function(player)
for i,v in pairs(workspace:GetChildren()) do
local HitBox = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-player.Character.HumanoidRootPart.Size.magnitude/2)
	if v:FindFirstChild("Humanoid") and v.Humanoid ~= player.Character.Humanoid and (v:FindFirstChild("HumanoidRootPart").CFrame.p -  HitBox.p).magnitude <= 3.5 then	
	local df = v.HumanoidRootPart.CFrame:pointToObjectSpace(player.Character.HumanoidRootPart.Position)	
	local damagehdlr = damage.new
	
	damage:Hit(10, v, "rbxassetid://278061737", player)	
	
	if df.z < 0 then
		print("you attacked from the front!")
			damage:KnockBack(v, game.ReplicatedStorage.combatanims.stun, 1, player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-10))
		end
		end
	end
end)

EDIT: I want the player that I'm hittings rotation to maintain it's starting orientation.

7 comments

0

multiply by the euler angles of the humanoid's root part. CFrame.Angles(HumanoidRootPart.CFrame:toEulerAnglesXYZ())

0

damage:KnockBack(v, game.ReplicatedStorage.combatanims.stun, 1, player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-10) * CFrame.Angles(v.HumanoidRootPart.CFrame:toEulerAnglesXYZ())) Like so?

0

https://gyazo.com/c23f9b5fcf0eb696046fc2bab947aeef I used that line of code, not quite but close.

0

player.Character.HumanoidRootPart.CFrame also contains the rotation values from the root part's cframe. remember, cframe is position and orientation.

0

instead of utilizing the attacker's cframe, use the defender's cframe lookvector times a constant, which should be negative so the defender will be pushed backwards. or, you can use the look vector of the attacker and multiply it by a positive constant in order to move the defender relative to the attacker's facing direction

0

I had tried that initially, however, the result is that since LookVector is a Vector3 Value it would error..

0

Also, if I were to do that.. it wouldn’t go in the direction of my character but rather in the direction of theres.. so if I were to punch from the side they would go to the side instead of infront of me