Advertisement
Guest User

fsd

a guest
Dec 14th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.97 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local mouse = player:GetMouse()
  3. local clicking = true
  4. local function MakeHole(targ,face,hole)
  5.     local dif = targ.CFrame:toObjectSpace(mouse.Hit)
  6.     local offset = dif.p+targ.Size/2
  7.     local Size1,Size2,Size3,Size4
  8.     local CFrame1,CFrame2,CFrame3,CFrame4
  9.     if face == Enum.NormalId.Front or face == Enum.NormalId.Back then
  10.         Size1 = Vector3.new(
  11.             targ.Size.X-offset.X+hole/2,
  12.             math.abs(offset.Y-targ.Size.Y)-hole/2,
  13.             targ.Size.Z)
  14.         Size2 = Vector3.new(
  15.             targ.Size.X-math.abs(offset.X-targ.Size.X)-hole/2,
  16.             math.abs(offset.Y-targ.Size.Y)+hole/2,
  17.             targ.Size.Z)
  18.         Size3 = Vector3.new(
  19.             targ.Size.X-offset.X-hole/2,
  20.             targ.Size.Y-math.abs(offset.Y-targ.Size.Y)+hole/2,
  21.             targ.Size.Z)
  22.         Size4 = Vector3.new(
  23.             targ.Size.X-math.abs(offset.X-targ.Size.X)+hole/2,
  24.             targ.Size.Y-math.abs(offset.Y-targ.Size.Y)-hole/2,
  25.             targ.Size.Z)
  26.         CFrame1 = targ.CFrame*CFrame.new(dif.X+Size1.X/2-hole/2,dif.Y+Size1.Y/2+hole/2,0)
  27.         CFrame2 = targ.CFrame*CFrame.new(dif.X-Size2.X/2-hole/2,dif.Y+Size2.Y/2-hole/2,0)
  28.         CFrame3 = targ.CFrame*CFrame.new(dif.X+Size3.X/2+hole/2,dif.Y-Size3.Y/2+hole/2,0)
  29.         CFrame4 = targ.CFrame*CFrame.new(dif.X-Size4.X/2+hole/2,dif.Y-Size4.Y/2-hole/2,0)
  30.     elseif face == Enum.NormalId.Top or face == Enum.NormalId.Bottom then
  31.         Size1 = Vector3.new(
  32.             targ.Size.X-offset.X-hole/2,
  33.             targ.Size.Y,
  34.             targ.Size.Z-math.abs(offset.Z-targ.Size.Z)+hole/2)
  35.         Size2 = Vector3.new(
  36.             targ.Size.X-math.abs(offset.X-targ.Size.X)+hole/2,
  37.             targ.Size.Y,
  38.             targ.Size.Z-math.abs(offset.Z-targ.Size.Z)-hole/2)
  39.         Size3 = Vector3.new(
  40.             targ.Size.X-offset.X+hole/2,
  41.             targ.Size.Y,
  42.             math.abs(offset.Z-targ.Size.Z)-hole/2)
  43.         Size4 = Vector3.new(
  44.             targ.Size.X-math.abs(offset.X-targ.Size.X)-hole/2,
  45.             targ.Size.Y,
  46.             math.abs(offset.Z-targ.Size.Z)+hole/2)
  47.         CFrame1 = targ.CFrame*CFrame.new(dif.X+Size1.X/2+hole/2,0,dif.Z-Size1.Z/2+hole/2)
  48.         CFrame2 = targ.CFrame*CFrame.new(dif.X-Size2.X/2+hole/2,0,dif.Z-Size2.Z/2-hole/2)
  49.         CFrame3 = targ.CFrame*CFrame.new(dif.X+Size3.X/2-hole/2,0,dif.Z+Size3.Z/2+hole/2)
  50.         CFrame4 = targ.CFrame*CFrame.new(dif.X-Size4.X/2-hole/2,0,dif.Z+Size4.Z/2-hole/2)
  51.     elseif face == Enum.NormalId.Right or face == Enum.NormalId.Left then
  52.         Size1 = Vector3.new(
  53.             targ.Size.X,
  54.             math.abs(offset.Y-targ.Size.Y)+hole/2,
  55.             targ.Size.Z-offset.Z-hole/2)
  56.         Size2 = Vector3.new(
  57.             targ.Size.X,
  58.             math.abs(offset.Y-targ.Size.Y)-hole/2,
  59.             targ.Size.Z-math.abs(offset.Z-targ.Size.Z)+hole/2)
  60.         Size3 = Vector3.new(
  61.             targ.Size.X,
  62.             targ.Size.Y-math.abs(offset.Y-targ.Size.Y)-hole/2,
  63.             targ.Size.Z-offset.Z+hole/2)
  64.         Size4 = Vector3.new(
  65.             targ.Size.X,
  66.             targ.Size.Y-math.abs(offset.Y-targ.Size.Y)+hole/2,
  67.             targ.Size.Z-math.abs(offset.Z-targ.Size.Z)-hole/2)
  68.         CFrame1 = targ.CFrame*CFrame.new(0,dif.Y+Size1.Y/2-hole/2,dif.Z+Size1.Z/2+hole/2)
  69.         CFrame2 = targ.CFrame*CFrame.new(0,dif.Y+Size2.Y/2+hole/2,dif.Z-Size2.Z/2+hole/2)
  70.         CFrame3 = targ.CFrame*CFrame.new(0,dif.Y-Size3.Y/2-hole/2,dif.Z+Size3.Z/2-hole/2)
  71.         CFrame4 = targ.CFrame*CFrame.new(0,dif.Y-Size4.Y/2+hole/2,dif.Z-Size4.Z/2-hole/2)
  72.     end
  73.     local Part1 = targ:Clone()
  74.     local Part2 = targ:Clone()
  75.     local Part3 = targ:Clone()
  76.     local Part4 = targ:Clone()
  77.     Part1.Size = Size1
  78.     Part2.Size = Size2
  79.     Part3.Size = Size3
  80.     Part4.Size = Size4
  81.     Part1.CFrame = CFrame1
  82.     Part2.CFrame = CFrame2
  83.     Part3.CFrame = CFrame3
  84.     Part4.CFrame = CFrame4
  85.     Part1.Parent = targ.Parent
  86.     Part2.Parent = targ.Parent
  87.     Part3.Parent = targ.Parent
  88.     Part4.Parent = targ.Parent
  89.     targ:Destroy()
  90. end
  91. mouse.Button1Up:connect(function()
  92.     clicking = false
  93. end)
  94. mouse.Button1Down:connect(function()
  95.     local targ = mouse.Target
  96.     local hole = 1
  97.     local dif = Vector3.new(hole,hole,hole)/2
  98.     local region = Region3.new(mouse.Hit.p-dif,mouse.Hit.p+dif)
  99.     for i,v in pairs(game.Workspace:FindPartsInRegion3(region))do
  100.         MakeHole(v,mouse.TargetSurface,hole)
  101.     end
  102.     local newsound = script.Sound:Clone()
  103.     newsound.Parent = script
  104.     newsound:Play()
  105.     game.Debris:AddItem(newsound,.5)
  106. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement