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

Detecting if a player is "outside"?

Not quite sure where to start here. I want to check if a player is outside, meaning there are no blocks above them. Any ideas or solutions on where to start? I just need this part, I can do the rest of the blizzard script.

1 answer

✓ Accepted answer

You could use a ray to find out if there's a part immediately above the character's head. In a nutshell, a ray is a line that is finite in one direction and infinite in the other.

function isInside (char)
	local head = char:WaitForChild("Head")
	local ray = Ray.new(head.Position , Vector3.new(0 , 1 , 0) * 999)
	if workspace:FindPartOnRay(ray , char) then return true end
	return false
end

Basically, the idea is to make a ray that starts at the head's position and goes upwards. If the ray intersects with a part then the player is indoors. We also need to pass in the character instance as a parameter to tell that the ray should ignore any descendants of the character model.

4 comments

0

Actually, problem popped up with this.

0

The ray you create always points South. How would I make it point straight upwards?

0

Fixed!

0

You accepted answer after one year. Noice

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