Advertisement
Quoteory

Untitled

Aug 5th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. local minPart = workspace.min
  2. local maxPart = workspace.max
  3. local partToCheck = workspace.CheckPart
  4.  
  5. local minPos = minPart.Position
  6. local maxPos = maxPart.Position
  7.  
  8. function betweenAxis(axis, axisMin, axisMax)
  9.     return (axis > axisMin) and (axis < axisMax)
  10. end
  11.  
  12. function inbetweenPos(pos, min, max)
  13.     local posx, minx, maxx = pos.X, min.X, max.X
  14.     local posy, miny, maxy = pos.Y, min.Y, max.Y
  15.     local posz, minz, maxz = pos.Z, min.Z, max.Z
  16.    
  17.     return betweenAxis(posx, minx, maxx) and betweenAxis(posy, miny, maxy) and betweenAxis(posz, minz, maxz)
  18.    
  19. end
  20.  
  21. while true do
  22.    
  23.     local pos = partToCheck.Position
  24.    
  25.     if inbetweenPos(pos, minPos, maxPos) then
  26.         partToCheck.BrickColor = BrickColor.Green()
  27.     else
  28.         partToCheck.BrickColor = BrickColor.Red()
  29.     end
  30.    
  31.     wait()
  32.    
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement