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

Raycast not detecting terrain?

Asked by 5 years ago

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

Log in to vote
-1
Answered by 5 years ago

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)
Ad

Answer this question