Hi, I’m trying to do hovercraft and in it I have a script that calculates the distance between the hovercraft and anything else (Parts, terrain, etc.) However, there is a problem because raycast does not work as I would like. It calculates the distance, but up to a certain distance or size of part. for example, if the part is too big, raycast ignores it, or if the part is too close or too far, it ignores it
This is my first time trying to do a script using raycast so I don’t really get it. I’m trying to learn it.
local PilotSeat = script:WaitForChild("PilotSeat").Value
local R = Ray.new(PilotSeat.Position, Vector3.new(0,-100,0))
local PartFound, Pos
local DistanceToGround
RunService.Heartbeat:Connect(function()
PartFound, Pos = workspace:FindPartOnRay(R)
if PartFound then
print("Part: "..PartFound.Name)
DistanceToGround = PilotSeat.Parent.Position.Y - PartFound.Position.Y
end
print("Distance: "..DistanceToGround)
end)
Blue part is called Z, and gray part is called X