My goal is to shoot a Raycast in the direction the player is facing that goes 50 studs, however, I do not know how to do this. I can’t find anyone else with this issue either.
This is my current code, but it does not work.
local rayOrigin = player.Character.HumanoidRootPart.Position
local rayDirection = player.Character.HumanoidRootPart.CFrame.LookVector
local raycastResult = workspace:Raycast(rayOrigin, rayDirection)
print(raycastResult)
This is because you’re not constantly printing the updated result, but you’re only printing the result when it’s first established. To test, instead do this:
local rayOrigin = player.Character.HumanoidRootPart.Position
local rayDirection = player.Character.HumanoidRootPart.CFrame.LookVector
while task.wait() do
local raycastResult = workspace:Raycast(rayOrigin, rayDirection)
print(raycastResult)
end
Correct me if I am wrong. But doesn’t .LookVector give you a normalized Vector (values 0 to 1) you can just multiply it by 50 to take the range of the ray into account: