Let's say you can only build inside a certain restricted area, how would I check if the mouse is inside that area so that you can place in there? I tried this:
spawn(function() mouse.Move:Connect(function() if mouse.Hit.p < region.CFrame.p and region.Hit.p < mouse.CFrame.p then print("yep") end end) end)
But errored that I can't compare 2 userdata values.
Since you can't compare userdata with each other, you'll have to compare each individual axis with each other instead.
like such:
-- This function will take two vector as arguments and -- compare break it down to axis and then compare -- each axis value with each other. function compareVectors(v1,v2) local x1,y1,z1 = v1.x, v1.y, v1.z local x2,y2,z2 = v2.x, v2.y, v2.z return x1 < x2 and y1 < y2 and z1 < z2 end spawn(function() mouse.Move:Connect(function() local check1 = compareVectors(mouse.Hit.p,region.CFrame.p) local check2 = compareVectors(region.Hit.p,mouse.CFrame.p) if check1 and check2 then print("yep") end end) end)