What I am trying to do is teleport the player 8 directionally based on which direction they’re moving using their keys pressed.
local W = UIS:IsKeyDown(Enum.KeyCode.W)
local A = UIS:IsKeyDown(Enum.KeyCode.A)
local S = UIS:IsKeyDown(Enum.KeyCode.S)
local D = UIS:IsKeyDown(Enum.KeyCode.D)
local direction = Vector3.new(0,0,0)
if W then direction += Vector3.new(0,0,-1) end
if A then direction += Vector3.new(1,0,0) end
if S then direction += Vector3.new(0,0,1) end
if D then direction += Vector3.new(-1,0,0) end
direction = direction.Unit
local params = RaycastParams.new()
params.FilterDescendantsInstances = {char}
params.FilterType = Enum.RaycastFilterType.Exclude
local raycast = workspace:Spherecast((humrp.CFrame * CFrame.new(0,0,2)).Position, 2, direction *20, params)
The direction variable does work properly (for example holding W and A does give (1,0,-1) which is the correct direction), but I want to convert it into a raycast that will start from the player’s cframe to whatever the direction is, and I’m not sure how to go about doing that.