Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- local clicking = true
- local function MakeHole(targ,face,hole)
- local dif = targ.CFrame:toObjectSpace(mouse.Hit)
- local offset = dif.p+targ.Size/2
- local Size1,Size2,Size3,Size4
- local CFrame1,CFrame2,CFrame3,CFrame4
- if face == Enum.NormalId.Front or face == Enum.NormalId.Back then
- Size1 = Vector3.new(
- targ.Size.X-offset.X+hole/2,
- math.abs(offset.Y-targ.Size.Y)-hole/2,
- targ.Size.Z)
- Size2 = Vector3.new(
- targ.Size.X-math.abs(offset.X-targ.Size.X)-hole/2,
- math.abs(offset.Y-targ.Size.Y)+hole/2,
- targ.Size.Z)
- Size3 = Vector3.new(
- targ.Size.X-offset.X-hole/2,
- targ.Size.Y-math.abs(offset.Y-targ.Size.Y)+hole/2,
- targ.Size.Z)
- Size4 = Vector3.new(
- targ.Size.X-math.abs(offset.X-targ.Size.X)+hole/2,
- targ.Size.Y-math.abs(offset.Y-targ.Size.Y)-hole/2,
- targ.Size.Z)
- CFrame1 = targ.CFrame*CFrame.new(dif.X+Size1.X/2-hole/2,dif.Y+Size1.Y/2+hole/2,0)
- CFrame2 = targ.CFrame*CFrame.new(dif.X-Size2.X/2-hole/2,dif.Y+Size2.Y/2-hole/2,0)
- CFrame3 = targ.CFrame*CFrame.new(dif.X+Size3.X/2+hole/2,dif.Y-Size3.Y/2+hole/2,0)
- CFrame4 = targ.CFrame*CFrame.new(dif.X-Size4.X/2+hole/2,dif.Y-Size4.Y/2-hole/2,0)
- elseif face == Enum.NormalId.Top or face == Enum.NormalId.Bottom then
- Size1 = Vector3.new(
- targ.Size.X-offset.X-hole/2,
- targ.Size.Y,
- targ.Size.Z-math.abs(offset.Z-targ.Size.Z)+hole/2)
- Size2 = Vector3.new(
- targ.Size.X-math.abs(offset.X-targ.Size.X)+hole/2,
- targ.Size.Y,
- targ.Size.Z-math.abs(offset.Z-targ.Size.Z)-hole/2)
- Size3 = Vector3.new(
- targ.Size.X-offset.X+hole/2,
- targ.Size.Y,
- math.abs(offset.Z-targ.Size.Z)-hole/2)
- Size4 = Vector3.new(
- targ.Size.X-math.abs(offset.X-targ.Size.X)-hole/2,
- targ.Size.Y,
- math.abs(offset.Z-targ.Size.Z)+hole/2)
- CFrame1 = targ.CFrame*CFrame.new(dif.X+Size1.X/2+hole/2,0,dif.Z-Size1.Z/2+hole/2)
- CFrame2 = targ.CFrame*CFrame.new(dif.X-Size2.X/2+hole/2,0,dif.Z-Size2.Z/2-hole/2)
- CFrame3 = targ.CFrame*CFrame.new(dif.X+Size3.X/2-hole/2,0,dif.Z+Size3.Z/2+hole/2)
- CFrame4 = targ.CFrame*CFrame.new(dif.X-Size4.X/2-hole/2,0,dif.Z+Size4.Z/2-hole/2)
- elseif face == Enum.NormalId.Right or face == Enum.NormalId.Left then
- Size1 = Vector3.new(
- targ.Size.X,
- math.abs(offset.Y-targ.Size.Y)+hole/2,
- targ.Size.Z-offset.Z-hole/2)
- Size2 = Vector3.new(
- targ.Size.X,
- math.abs(offset.Y-targ.Size.Y)-hole/2,
- targ.Size.Z-math.abs(offset.Z-targ.Size.Z)+hole/2)
- Size3 = Vector3.new(
- targ.Size.X,
- targ.Size.Y-math.abs(offset.Y-targ.Size.Y)-hole/2,
- targ.Size.Z-offset.Z+hole/2)
- Size4 = Vector3.new(
- targ.Size.X,
- targ.Size.Y-math.abs(offset.Y-targ.Size.Y)+hole/2,
- targ.Size.Z-math.abs(offset.Z-targ.Size.Z)-hole/2)
- CFrame1 = targ.CFrame*CFrame.new(0,dif.Y+Size1.Y/2-hole/2,dif.Z+Size1.Z/2+hole/2)
- CFrame2 = targ.CFrame*CFrame.new(0,dif.Y+Size2.Y/2+hole/2,dif.Z-Size2.Z/2+hole/2)
- CFrame3 = targ.CFrame*CFrame.new(0,dif.Y-Size3.Y/2-hole/2,dif.Z+Size3.Z/2-hole/2)
- CFrame4 = targ.CFrame*CFrame.new(0,dif.Y-Size4.Y/2+hole/2,dif.Z-Size4.Z/2-hole/2)
- end
- local Part1 = targ:Clone()
- local Part2 = targ:Clone()
- local Part3 = targ:Clone()
- local Part4 = targ:Clone()
- Part1.Size = Size1
- Part2.Size = Size2
- Part3.Size = Size3
- Part4.Size = Size4
- Part1.CFrame = CFrame1
- Part2.CFrame = CFrame2
- Part3.CFrame = CFrame3
- Part4.CFrame = CFrame4
- Part1.Parent = targ.Parent
- Part2.Parent = targ.Parent
- Part3.Parent = targ.Parent
- Part4.Parent = targ.Parent
- targ:Destroy()
- end
- mouse.Button1Up:connect(function()
- clicking = false
- end)
- mouse.Button1Down:connect(function()
- local targ = mouse.Target
- local hole = 1
- local dif = Vector3.new(hole,hole,hole)/2
- local region = Region3.new(mouse.Hit.p-dif,mouse.Hit.p+dif)
- for i,v in pairs(game.Workspace:FindPartsInRegion3(region))do
- MakeHole(v,mouse.TargetSurface,hole)
- end
- local newsound = script.Sound:Clone()
- newsound.Parent = script
- newsound:Play()
- game.Debris:AddItem(newsound,.5)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement