Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 1 year 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
0
Answered by 1 year 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
else
    --Raycast hit below Y<40 and dont do anything
end
Ad

Answer this question