Raycasting to detect terrain?

I tested the place. First things first, the code is in a local script so it doesn’t run. You need to place it in a server script if you want it to run server-side.

Also I’ve found out the issue. The problem is that the position of the raft is already in the water, so it ignores the water and the next thing the ray picks up is the grass underneath. Rays have this weird thing where if the starting position is within a part, it ignores that part. To fix this is simple, set the starting position of the ray to be a little bit higher than the raft position. I changed the first line to this and it worked:

YourRayHere = Ray.new(workspace.Raft.Position + Vector3.new(0, 10, 0), Vector3.new(0,-10,0)*100)
5 Likes