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

Raycast not detecting terrain?

I am trying to make a sort of item drop system however i want it to drop on certain terrain however, i cant detect terrain! Here is my code:

local x = math.random(-1300,1300)

local z = math.random(-1300,1300)

local ray = Ray.new(Vector3.new(x,500,z), Vector3.new(90,0,0))

local part, position = workspace:FindPartOnRay(ray, workspace.Spawn, true, false)

print(part)

This only returns nil, so i have no idea what the problem is

1 answer

i found the problem it was because the racast was too high

here is now what i have:

local x = math.random(-1300,1300)
local z = math.random(-1300,1300)
local ray = Ray.new(Vector3.new(x,180,z), Vector3.new(0,-180,0))
local part, position, norm, mat = workspace:FindPartOnRay(ray)
print(mat, position, part, norm)

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