How to make a sword blocking system but when you hit the back of the player blocking it still deals damage?

So basically im asking how to script a sword blocking system but when you hit the front of the player blocking, the player blocking will not receive any damage, but if you hit the back of the player blocking, it will deal damage.

1 Like

You can achieve this with Dot product;

local TargetPosition = Victim.HumanoidRootPart.Position -- Target position (Assume this is a player blocking)
local attackerPos = Backstabber.HumanoidRootPart.Position -- Our position
local Direction = (attackerPos - TargetPosition).Unit
local targetLV = Victim.HumanoidRootPart.CFrame.LookVector.Unit
local Result = Direction:Dot(targetLV)

if Result < -0.5 then
	print("Back, DMG")
else
	print("Front, no DMG")
end
13 Likes