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

While hit by raycast help?

Asked by 4 years ago

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

Log in to vote
0
Answered by
ArtBlart 533 Moderation Voter
4 years ago

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.

Ad

Answer this question