Create a ray that looks straight ahead in front of the player

Hello, I'm trying to create a ray that looks straight ahead in front of the player.

(Sorry for the bad artwork)

I tried to multiplicate the player's transform's forward vector by another vector but I had no luck.

Any suggestions?

Hello! In order to get the forward vector, you can take the world rotation of the object (object:GetWorldRotation()) then multiply it by Vector3.FORWARD. An example is:

local TestGroup = script:GetCustomProperty("Group"):WaitForObject()

local DISTANCE = 100

local function getForwardVector()
   local rotation = TestGroup:GetWorldRotation()

   return rotation * Vector3.FORWARD

function drawForwardVector(forwardVector)
    local position = TestGroup:GetWorldPosition()

    CoreDebug.DrawLine(position, position + (forwardVector * DISTANCE), {
        thickness = 5,

function Tick()
    forwardVector = getForwardVector()

TestGroup:RotateContinuous(Rotation.New(0, 0, -180), 0.1)

That script will continuously rotate the object and draw the forward vector, however the actual utility is in getForwardVector()

1 Like

Thank you very much

1 Like