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

Raycast not facing behind a part?

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

2 comments

0

is this the whole script? send us the whole script.

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

1 answer

Don't put parenthesis in "RayCastHit" on If not (RayCastHit) then

Your code should work fine now

2 comments

0

that makes no difference. brackets do not matter in this case

0

Parentheses enable precedence, and they are necessary in logic conditions from time-to-time.

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