Hello! I am new into raycasting and I've made a script that makes a raycast, however I'd like to know how do I approach making it so whenever it hovers over a part, the part's color turns red, and whenever it gets off the part, the part's color turns white.
Thanks for your time!
You should use Workspace:FindPartOnRay. The first thing the function returns is the part it hit, which will either be a part or nil.
Code examples can be found on the wiki. There are also various deviations of FindPartOnRay
like FindPartOnRayWithIgnoreList
and FindPartOnRayWithWhitelist
. They have their own use cases and If you need to use them, they function similar to FindPartOnRay.