Knock back using ray cast and tween

Alr basically we have a hitbox which supposed to knock back the player a small distance but i have no idea how to do it.

i have already tried using a body velocity into the player to move them back but it dosent feel right at all, so i decided to use tween and look vector to move the player backwards at all times so you dont move forward or side to side, just backwards facing away from the camrea.

So how do i tween the player back using HumanoidRootPart.CFrame.LookVector to move the player back a set distance (example X: -50) on look vector and since tweening sort of ignores walls, how would i use raycasting to detect walls and make the player stop infront of the wall.

(this script goes into a hitbox part)

1 Like

If you just want to knock back the player like in Minecraft then you can just change AssemblyLinearVelocity of player’s root part by utilizing LookVector and UpVector, so I dont think that you need ray cast and tween for this.

root.AssemblyLinearVelocity = root.Position + (root.CFrame.LookVector * -25) + (root.CFrame.UpVector * 25)
1 Like