Advertisement
lafur

Untitled

May 21st, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. --building v2 test--
  3.  
  4.  
  5. plr = owner
  6. char = plr.Character
  7. mouse = plr:GetMouse()
  8. Mouse = mouse
  9.  
  10. function SnapToGrid(x, gridX)
  11. local x = math.floor((x / gridX) + 0.5) * gridX
  12. return x
  13. end
  14.  
  15. mouse.Button1Down:connect(function()
  16. if mouse.Target then
  17. local target = mouse.Target
  18. local block = Instance.new("Part",workspace)
  19. block.Anchored = true
  20.  
  21.  
  22. local x = Mouse.Target.CFrame.p.X
  23. local y = Mouse.Target.CFrame.p.Y
  24. local z = Mouse.Target.CFrame.p.Z
  25. if Mouse.TargetSurface.Name == "Right" then x = x + 2.6 end
  26. if Mouse.TargetSurface.Name == "Left" then x = x - 2.6 end
  27. if Mouse.TargetSurface.Name == "Top" then y = y + 2.6 end
  28. if Mouse.TargetSurface.Name == "Bottom" then y = y - 2.6 end
  29. if Mouse.TargetSurface.Name == "Back" then z = z + 2.6 end
  30. if Mouse.TargetSurface.Name == "Front" then z = z - 2.6 end
  31. -- local y = round(math.abs(mouseY)/2.6)*2.6
  32. -- local z = round(math.abs(mouseZ)/2.6)*2.6
  33. -- if Mouse.Hit.p.X < 0 then x = x * -1 end
  34. -- if Mouse.Hit.p.Y < 0 then y = y * -1 end
  35. -- if Mouse.Hit.p.Z < 0 then z = z * -1 end
  36. block.Size = Vector3.new(4, 4, 4)
  37. block.CFrame = CFrame.new(SnapToGrid(x, 4), SnapToGrid(y, 4), SnapToGrid(z, 4))
  38. end
  39. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement