Im making a rain system and when someone goes indoors I want it to turn a particle off. Any ideas?
✓ ANSWER ACCEPTED
How do i check if a player is under a parts?
1 answer
✓ Accepted answer
You can use Raycasting which fires a ray above the player
local ray = Ray.new(player.Character.HumanoidRootPart,Vector3.new(0,100,0) -- creates a ray which goes 100 studs up from the HumanoidRootPart
local ignoreList = player.Character -- optional
local found = workspace:FindPartOnRay(ray,ignoreList or nil)
You can go on from there to check if found is a roof.
This discussion is preserved as it was. New answers, comments, and votes are closed.

17 comments
How would i check if its touching a part though? (Any part)
You can use the found variable to check if it's a part or not
what does found return?
It returns a BasePart or nil
Okay, it also gives an error saying attempt to index nil with 'HumanoidRootPart' on line 1
BasePart/Terrain or nil*
Is player defined?
ye, i did game.Players.LocalPlayer.Character.HumanoidRootPart
Do a wait at that beginning of your script to let the character load in
Fixed it but now it says invalid argument #1 (Vector3 expected, got Instance)
Add another ) at the end of Vector3.new(0,100,0)
I already did that before
local ray = Ray.new(game.Players.LocalPlayer.Character.HumanoidRootPart,Vector3.new(0,100,0))
Oh, add .Position after HumanoidRootPart
Works, just keeps printing "Nil" even if i go under a part (i put it in a while loop)
Do you have an ignoreList
Nvm, i fixed it. I wasnt making another ray in the loop, bc if u move around u gotta make a new ray. Answer accepted