how to detect player in area roblox code example

Example: Roblox check if plr is in area

--local script under the detector part, I believe 'HymanoidRootPart' could be
--also set to the feet but idk how do do that.

local Part = script.Parent
Part.Touched:Connect(function() end) -- Just for a TouchInterest to occur on a CanCollide false part

function CheckIfPlayerIsInArea(Part,Character)
    local touching = Part:GetTouchingParts()
	for i=1,#touching do
		if touching[i] == Character.HumanoidRootPart then
			return true
		end
	end
	return false
end

-hope this helps :)

Tags:

Lua Example