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

While hit by raycast help?

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!

1 answer

✓ Accepted answer

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.

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