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

Raycast not facing behind a part?

Asked by 2 years ago

Hello.

I'm currently trying to make a Raycast detect when an object / part is in the air. My game involves the user being able to place down notes wherever they want if allowed.

Now, there is a way to exploit this by placing the notes on the air, and to combat this I thought using a raycast on the server to check if the part is in the air would be the best solution.

So essentially, my goal is to get a ray to be casted from behind the note so it would hit either a wall, the floor or the roof.

Here's my code so far:

local RayMaximumRange = 2
local RayCastHit = workspace:Raycast(NoteClone.Note.Position, -NoteClone.Note.CFrame.LookVector * RayMaximumRange)

if not (RayCastHit) then
    print("Is in the air ")
end

I'm new to raycasts so I'm actually kind of clueless at the moment.

If I could get some help with this, It'd be great.

Thanks

0
is this the whole script? send us the whole script. JesseSong 3916 — 2y
0
this is just the raycast part of the script., the whole script just consists of setting an orientation of the note based on what side the wall is facing, and filtering the text that is wrtitten on the text RazzyPlayz 497 — 2y

1 answer

Log in to vote
-1
Answered by 2 years ago
Edited 2 years ago

Don't put parenthesis in "RayCastHit" on

If not (RayCastHit) then

Your code should work fine now

0
that makes no difference. brackets do not matter in this case JesseSong 3916 — 2y
0
Parentheses enable precedence, and they are necessary in logic conditions from time-to-time. Ziffixture 6913 — 2y
Ad

Answer this question