function PlaneIntersection(h)local c=false local j=(game:GetService("\087\111\114\107\115\112\097\099\101")).CurrentCamera local f=Vector3.new(j.CoordinateFrame.p.X,j.CoordinateFrame.p.Y,j.CoordinateFrame.p.Z)local M=Vector3.new(h.X,h.Y,h.Z)local P=Vector3.new(0,1,0)local d=Vector3.new(0,0,0)local T=P:Dot(M-f)local o=h if T~=0 then local h=P:Dot(d-f)/T if h>=0 and h<=1 then local j=(M-f)*h+f o=(game:GetService("\087\111\114\107\115\112\097\099\101")).Terrain:WorldToCell(j)c=true end end return o,c end

function PlaneIntersection(vectorPos)
	local hit = false
	local currCamera = game:GetService("Workspace").CurrentCamera
	local startPos = Vector3.new(currCamera.CoordinateFrame.p.X, currCamera.CoordinateFrame.p.Y, currCamera.CoordinateFrame.p.Z)
	local endPos = Vector3.new(vectorPos.X, vectorPos.Y, vectorPos.Z)
	local normal = Vector3.new(0, 1, 0)
	local p3 = Vector3.new(0, 0, 0)
	local startEndDot = normal:Dot(endPos - startPos)
	local cellPos = vectorPos
	if startEndDot ~= 0  then
		local t = normal:Dot(p3 - startPos) / startEndDot
		if(t >=0 and t <=1) then
			local intersection = ((endPos - startPos) * t) + startPos
			cellPos = game:GetService("Workspace").Terrain:WorldToCell(intersection)
			hit = true
		end
	end

	return cellPos, hit
end

