Log in to vote

Make a raycast stop before a boundary without using any basepart?

Asked by 24 days ago

So I was wondering if I could get a raycast to stop or get the position of the raycast in the stopped place without using any parts to do this

so basically if a raycast is used and it passes the 40 on y axis

i want it to stop and i want to get a way to get the postion of the raycast without USING Parts

1 answer

Log in to vote
Answered by 23 days ago

The end position of the raycast if it doesn't hit anything is the raycast origin + raycast direction. If you dont want anything to happen if a raycast hits something under y=40, you just add a check to ignore anything that is below y=40.

local RayCast = game.Workspace:RayCast(stuff)
if RayCast and RayCast.Position.Y > 40 then
    -- do stuff
elseif not RayCast
    --Raycast didnt hit anything
    -- Enpoint is raycast origin + raycast direction
    --Raycast hit below Y<40 and dont do anything

Answer this question