Advertisement
Treyzotic

Grid

May 18th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local mouse = player:GetMouse()
  3.  
  4. local Grid = game.Workspace.Grid
  5. local GridSize = (4/2)
  6. local Offset = .2
  7. local Marker = game.Workspace.Marker
  8.  
  9. local PosX = Marker.CFrame.X
  10. local PosY = Marker.CFrame.Y
  11. local PosZ = Marker.CFrame.Z
  12.  
  13. mouse.Move:Connect(function()
  14. if mouse.Target == Grid then
  15. mouse.TargetFilter = game.Workspace.Marker
  16. Marker.Position = Vector3.new((math.floor(mouse.Hit.X / GridSize +.5 ) * GridSize) - .575, mouse.Hit.Y, (math.floor(mouse.Hit.Z / GridSize + .5) * GridSize) )
  17. end
  18. end)
  19. local Done = false
  20. local part
  21. local OldMarker
  22. mouse.Button1Down:Connect(function()
  23. if not Done then
  24. OldMarker = Marker:Clone()
  25. OldMarker.Parent = game.Workspace
  26. OldMarker.CFrame = Marker.CFrame
  27. part = Instance.new("Part")
  28. part.Size = Vector3.new(.1,Grid.Size.Y,.1)
  29. part.Anchored = true
  30. part.Position = Marker.Position
  31. part.TopSurface = Enum.SurfaceType.Smooth
  32. part.Parent = game.Workspace
  33. mouse.TargetFilter = part
  34. Done = true
  35. elseif Done then
  36. Done = false
  37. OldMarker:Destroy()
  38. end
  39. end)
  40. local Midpoint = function(x1, x2)
  41.  
  42. local Answer = ((x2 + x1)/2)
  43.  
  44. return Answer
  45.  
  46. end
  47. mouse.Button1Up:Connect(function()
  48. wait()
  49. spawn(function()
  50. while Done do
  51. part.Size = Vector3.new(math.abs((Marker.Position.X - OldMarker.Position.X)), .1, math.abs((Marker.Position.Z - OldMarker.Position.Z)))
  52. part.CFrame = CFrame.new(Midpoint(OldMarker.CFrame.X, Marker.CFrame.X), part.Position.Y, Midpoint(OldMarker.CFrame.Z, Marker.CFrame.Z))
  53. wait()
  54. end
  55. end)
  56. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement