Flip the part upside down then
When I test your code with the edit I made it works perfectly fine. It would be helpful to know what you are using this code for and if what I mentioned below doesnât fix your issue have a repro file which reproduces the issues you are facing. This is how I am testing your code:
Raycast Fix.rbxl (21.5 KB)
As you are using part.CFrame.UpVector
the ray wont go directly up from the part but instead go the direction of the UpVector. It could be possible that the part is upside down. Try flipping the part over or if the parts orientation doesnât matter change the 10th line to this so the ray always goes directly up:
local raycastResult = game.Workspace:Raycast(part.Position, Vector3.new(0, 1, 0) * 50, raycastParams)
Nope, I flipped the part in all directions and nothing happened. No errors, no printsâŚ
Itâs moments like these that feel so frusstrating about scripting because you couldâve done everything right and then u suspect that itâs the language code thatâs bugged and not urs.
Yeah, I couldnât figure it out for 4 days, which is delaying my learning process. I tried to avoid as much as I can.
It worked! Thanks soo much!