Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.