Weird issue with my raycast [simple]

soo i tried to make a raycast between two object and print something if there object between two of them but it’s keep printing nil and i don’t know how to really fix that i follow some of the tutorials on devforum but it’s still keep printing nil

i’m sure this issue it’s simple and not that hard but i can’t figure out

local a = workspace.a
local b = workspace.b

local diraction = a.Position - b.Position

local raycast = workspace:Raycast(a.Position, diraction)

print(raycast) --> nil

image

direction = goal - origin
You’re casting a ray from a in the direction of a to b, you need to swap a.Position and b.Position in your direction formula

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.