I want to create knockback that knocks a player back in the direction that the attacker is facing. So I used VectorForce, and set the Force to Vector3.new(0,2500,5000). Thing is, if the target is shiftlocked, then they can control the direction they get knocked back in, since it just knocks them backwards of where they are currently facing. I tried to use a BodyGyro to fix this issue, but to no avail. This is my code:
local knockbackdir = player.Character.HumanoidRootPart.CFrame.LookVector
local bg = Instance.new("BodyGyro")
bg.Parent = v.Parent:WaitForChild("HumanoidRootPart")
bg.D = 0
bg.P = 500000
bg.CFrame = CFrame.lookAt(v.Parent:WaitForChild("HumanoidRootPart").Position, knockbackdir)
local att = Instance.new("Attachment")
att.Parent = v.Parent:WaitForChild("HumanoidRootPart")
local vf = Instance.new("VectorForce")
vf.Parent = v.Parent:WaitForChild("HumanoidRootPart")
vf.Attachment0 = att
vf.Force = Vector3.new(0,2500,5000)
Any help would be greatly appreciated!
P.S. I’m a little new to scripting, so I’d appreciate it if you commented code for me to input instead of telling me what I should change about it. Thank you!