local P,RS,UIS,Deb=game:GetService("Players"),game:GetService("RunService"),game:GetService("UserInputService"),game:GetService("Debris") local plr,cam,ter=P.LocalPlayer,workspace.CurrentCamera,workspace.Terrain local V3=Vector3.new local C={Reach=9,R=6,Cell=2,Max=6,Imp=55,CD=.9,Life=12,MaxShards=600,RagTime=6,RagPow=70,Heavy=15,Bounce=.25,MinSpeed=14, Snd={"rbxassetid://9118616096","rbxassetid://9118617342","rbxassetid://9118615862"}} local power=1 local HS,HDS=V3(.35,4,.35),V3(1.1,1.1,2.1) local folder=Instance.new("Folder") folder.Name="ClientDebris" folder.Parent=workspace local flying,recs,trecs,rag={},{},{},{} local function spr(k,d,p) return {k=k,d=d,pos=p,vel=Vector3.zero,target=p} end local function upd(s,dt) local n=math.max(1,math.ceil(dt*120)) local h=dt/n for _=1,n do s.vel+=((s.target-s.pos)*s.k-s.vel*s.d)*h s.pos+=s.vel*h end end local function mk(size,mat,col) local p=Instance.new("Part") p.Size=size p.Material=mat p.Color=col p.CanCollide=false p.CanQuery=false p.CanTouch=false p.TopSurface=Enum.SurfaceType.Smooth p.BottomSurface=Enum.SurfaceType.Smooth return p end local function parts() local h=mk(HS,Enum.Material.Wood,Color3.fromRGB(110,75,45)) h.Name="Handle" return h,mk(HDS,Enum.Material.Metal,Color3.fromRGB(95,95,100)) end local function sound(pos) local a=mk(V3(.2,.2,.2),Enum.Material.Plastic,Color3.new()) a.Anchored=true a.Transparency=1 a.Position=pos a.Parent=folder for _,id in C.Snd do local s=Instance.new("Sound") s.SoundId=id s.Volume=1.2 s.RollOffMaxDistance=200 s.PlaybackSpeed=.9+math.random()*.2 s.Parent=a s:Play() end Deb:AddItem(a,5) end local function release(p,c) p.Anchored=false p.CanCollide=true local away=p.Position-c local d=away.Magnitude local dir=d>.01 and away.Unit or cam.CFrame.LookVector p.AssemblyLinearVelocity=dir*C.Imp*power*math.clamp(1-d/C.R,.25,1)+cam.CFrame.LookVector*25+V3(0,12+math.random()*10,0) p.AssemblyAngularVelocity=V3(math.random()-.5,math.random()-.5,math.random()-.5)*25 table.insert(flying,p) if #flying>C.MaxShards then local o=table.remove(flying,1) if o.Parent then o:Destroy() end end Deb:AddItem(p,C.Life) end local function findChar(i) local m=i:FindFirstAncestorWhichIsA("Model") while m do if m:FindFirstChildOfClass("Humanoid") then return m end m=m.Parent and m.Parent:FindFirstAncestorWhichIsA("Model") or nil end end local function piece(cls,size,cfr,part,ext,a,col) local p=Instance.new(cls) p.Size,p.CFrame,p.Material,p.Color,p.Reflectance,p.Transparency=size,cfr,part.Material,part.Color,part.Reflectance,part.Transparency p.Anchored,p.CanCollide=a,col pcall(function() p.MaterialVariant=part.MaterialVariant end) for _,f in {"Top","Bottom","Left","Right","Front","Back"} do p[f.."Surface"]=(ext and ext[f]) and part[f.."Surface"] or Enum.SurfaceType.Smooth end for _,d in part:GetChildren() do if d:IsA("SurfaceAppearance") or ((d:IsA("Decal") or d:IsA("Texture")) and ext and ext[d.Face.Name]) then d:Clone().Parent=p end end p.Parent=folder return p end local function extOf(mn,mx,h) local e=.01 return {Right=mx.X>=h.X-e,Left=mn.X<=-h.X+e,Top=mx.Y>=h.Y-e,Bottom=mn.Y<=-h.Y+e,Back=mx.Z>=h.Z-e,Front=mn.Z<=-h.Z+e} end local function shatter(part,c) local cf,half=part.CFrame,part.Size/2 local lp=cf:PointToObjectSpace(c) local R=C.R local b0=V3(math.max(-half.X,lp.X-R),math.max(-half.Y,lp.Y-R),math.max(-half.Z,lp.Z-R)) local b1=V3(math.min(half.X,lp.X+R),math.min(half.Y,lp.Y+R),math.min(half.Z,lp.Z+R)) local bs=b1-b0 if bs.X<.05 or bs.Y<.05 or bs.Z<.05 then return end local anch,cc=part.Anchored,part.CanCollide local whole=(b0+half).Magnitude<.01 and (b1-half).Magnitude<.01 local function block(mn,mx,a,col) local s=mx-mn if s.X<.05 or s.Y<.05 or s.Z<.05 then return end return piece("Part",s,cf*CFrame.new((mn+mx)/2),part,extOf(mn,mx,half),a,col) end local function wedges(mn,mx,a) local s=mx-mn local base,ws=cf*CFrame.new((mn+mx)/2),s local k=math.random(0,2) if k==1 then base*=CFrame.Angles(0,math.pi/2,0) ws=V3(s.Z,s.Y,s.X) elseif k==2 then base*=CFrame.Angles(0,0,math.pi/2) ws=V3(s.Y,s.X,s.Z) end if math.random()<.5 then base*=CFrame.Angles(0,math.pi,0) end return piece("WedgePart",ws,base,part,nil,a,true),piece("WedgePart",ws,base*CFrame.Angles(math.pi,0,0),part,nil,a,true) end if not whole then local P0,P1=-half,half for _,s in {{P0,V3(b0.X,P1.Y,P1.Z)},{V3(b1.X,P0.Y,P0.Z),P1},{V3(b0.X,P0.Y,P0.Z),V3(b1.X,b0.Y,P1.Z)}, {V3(b0.X,b1.Y,P0.Z),V3(b1.X,P1.Y,P1.Z)},{V3(b0.X,b0.Y,P0.Z),V3(b1.X,b1.Y,b0.Z)},{V3(b0.X,b0.Y,b1.Z),V3(b1.X,b1.Y,P1.Z)}} do block(s[1],s[2],anch,cc) end end local function n(s) return math.clamp(math.ceil(s/C.Cell),1,C.Max) end local nx,ny,nz=n(bs.X),n(bs.Y),n(bs.Z) local cell=V3(bs.X/nx,bs.Y/ny,bs.Z/nz) for x=0,nx-1 do for y=0,ny-1 do for z=0,nz-1 do local mn=b0+V3(cell.X*x,cell.Y*y,cell.Z*z) local mx=mn+cell local d=(cf*((mn+mx)/2)-c).Magnitude if whole or not anch or d<=R*(.6+math.random()*.4) then if math.random()<.6 then local a,b=wedges(mn,mx,true) release(a,c) release(b,c) else local p=block(mn,mx,true,true) if p then release(p,c) end end else local ex=extOf(mn,mx,half) if math.random()<.5 and not (ex.Top or ex.Bottom or ex.Left or ex.Right or ex.Front or ex.Back) then local _,b=wedges(mn,mx,true) release(b,c) else block(mn,mx,true,true) end end end end end if part.Parent~=folder then table.insert(recs,{part,part.Parent,part.CFrame,anch}) part.Parent=nil else part:Destroy() end end local function carveTerrain(c,mat) local r=C.R pcall(function() local a,b=ter:WorldToCell(c-V3(r,r,r)),ter:WorldToCell(c+V3(r,r,r)) local mn=Vector3int16.new(a.X-1,a.Y-1,a.Z-1) local reg=ter:CopyRegion(Region3int16.new(mn,Vector3int16.new(b.X+1,b.Y+1,b.Z+1))) table.insert(trecs,{reg,mn}) ter:FillBall(c,r,Enum.Material.Air) end) local col=Color3.fromRGB(120,100,80) pcall(function() col=ter:GetMaterialColor(mat) end) for _=1,14 do local p=mk(V3(1,1,1)*(.7+math.random()*.9),Enum.Material.Slate,col) p.Anchored=true p.Position=c+V3(math.random()-.5,math.random()*.8,math.random()-.5)*r p.Parent=folder release(p,c) end end local function hide(m,on,r) local h=m:FindFirstChildOfClass("Humanoid") if on then r.g={} for _,d in m:GetDescendants() do if d:IsA("BasePart") or d:IsA("Decal") then pcall(function() d.LocalTransparencyModifier=1 end) elseif d:IsA("BillboardGui") then r.g[d]=d.Enabled d.Enabled=false end end if h then r.dt=h.DisplayDistanceType h.DisplayDistanceType=Enum.HumanoidDisplayDistanceType.None end r.cn=m.DescendantAdded:Connect(function(d) if d:IsA("BillboardGui") then r.g[d]=true d.Enabled=false end end) else r.cn:Disconnect() for _,d in m:GetDescendants() do if d:IsA("BasePart") or d:IsA("Decal") then pcall(function() d.LocalTransparencyModifier=0 end) end end for g,e in r.g do if g.Parent then g.Enabled=e end end if h and r.dt then h.DisplayDistanceType=r.dt end end end local function restore(m) local r=rag[m] if not r then return end rag[m]=nil r.clone:Destroy() pcall(hide,m,false,r) end local function launch(clone,dir) for _,d in clone:GetDescendants() do if d:IsA("BasePart") then d.AssemblyLinearVelocity=dir*C.RagPow+V3(0,35,0) d.AssemblyAngularVelocity=V3(math.random()-.5,math.random()-.5,math.random()-.5)*18 end end end local function hitChar(m,c) local root=m:FindFirstChild("HumanoidRootPart") or m.PrimaryPart or m:FindFirstChildWhichIsA("BasePart") if not root then return end local flat=(root.Position-c)*V3(1,0,1) local dir=((flat.Magnitude>.01 and flat.Unit or cam.CFrame.LookVector)+cam.CFrame.LookVector).Unit if m:GetAttribute("RagdollClone") then launch(m,dir) return end if rag[m] then return end local old=m.Archivable m.Archivable=true local clone=m:Clone() m.Archivable=old if not clone then return end clone:SetAttribute("RagdollClone",true) local motors={} for _,d in clone:GetDescendants() do if d:IsA("BaseScript") or d:IsA("BillboardGui") then d:Destroy() elseif d:IsA("Motor6D") then table.insert(motors,d) end end for _,mo in motors do local p0,p1=mo.Part0,mo.Part1 if p0 and p1 then local a0,a1=Instance.new("Attachment"),Instance.new("Attachment") a0.CFrame,a1.CFrame=mo.C0,mo.C1 a0.Parent,a1.Parent=p0,p1 local b=Instance.new("BallSocketConstraint") b.Attachment0,b.Attachment1=a0,a1 b.LimitsEnabled=true b.UpperAngle=50 b.TwistLimitsEnabled=true b.TwistLowerAngle=-30 b.TwistUpperAngle=30 b.Parent=p0 local nc=Instance.new("NoCollisionConstraint") nc.Part0,nc.Part1=p0,p1 nc.Parent=p0 mo.Enabled=false end end for _,d in clone:GetDescendants() do if d:IsA("BasePart") then d.Anchored=false if d.Name=="HumanoidRootPart" then d.CanCollide=false end end end local h=clone:FindFirstChildOfClass("Humanoid") if h then h.BreakJointsOnDeath=false h.PlatformStand=true h.DisplayDistanceType=Enum.HumanoidDisplayDistanceType.None h.HealthDisplayType=Enum.HumanoidHealthDisplayType.AlwaysOff end clone.Parent=folder if h then h:ChangeState(Enum.HumanoidStateType.Physics) end launch(clone,dir) local r={clone=clone} rag[m]=r hide(m,true,r) if C.RagTime>0 then task.delay(C.RagTime,function() if rag[m]==r then restore(m) end end) end end local function hit(contact,pw) power=pw or 1 local rp=RaycastParams.new() rp.FilterType=Enum.RaycastFilterType.Exclude rp.FilterDescendantsInstances={plr.Character,cam} local o=cam.CFrame.Position local res=workspace:Raycast(o,cam.CFrame.LookVector*C.Reach,rp) if contact then local v=contact-o if v.Magnitude>.1 then res=workspace:Raycast(o,v.Unit*(v.Magnitude+2),rp) or res end end local c=res and res.Position or contact if not c then return false end sound(c) if res and res.Instance:IsA("Terrain") then carveTerrain(c,res.Material) end local op=OverlapParams.new() op.FilterType=Enum.RaycastFilterType.Exclude op.FilterDescendantsInstances={plr.Character,cam} local targets,chars={},{} for _,p in workspace:GetPartBoundsInRadius(c,C.R,op) do local ch=findChar(p) if ch then if ch~=plr.Character then chars[ch]=true end elseif p:IsA("BasePart") and not p:IsA("Terrain") and p.Transparency<1 and not p:GetAttribute("NoBreak") then table.insert(targets,p) end end for _,p in targets do if p.Parent then shatter(p,c) end end for ch in chars do hitChar(ch,c) end return true end local function resetAll() for _,x in folder:GetChildren() do x:Destroy() end table.clear(flying) for i=#recs,1,-1 do local r=recs[i] pcall(function() r[1].Parent=r[2] r[1].AssemblyLinearVelocity=Vector3.zero r[1].AssemblyAngularVelocity=Vector3.zero r[1].CFrame=r[3] r[1].Anchored=r[4] end) end table.clear(recs) for i=#trecs,1,-1 do pcall(function() ter:PasteRegion(trecs[i][1],trecs[i][2],true) end) end table.clear(trecs) for m in rag do restore(m) end end -- hammer collision local cp=OverlapParams.new() cp.FilterType=Enum.RaycastFilterType.Exclude cp.MaxParts=30 local tr=RaycastParams.new() tr.FilterType=Enum.RaycastFilterType.Include tr.FilterDescendantsInstances={ter} local function poseCFs(pos,rot) local h=cam.CFrame*CFrame.new(pos)*CFrame.Angles(rot.X,rot.Y,rot.Z)*CFrame.new(0,1.2,0) return h,h*CFrame.new(0,2.1,0) end local function collides(h,hd) for _,b in {{h,HS},{hd,HDS}} do for _,p in workspace:GetPartBoundsInBox(b[1],b[2],cp) do if p.CanCollide and (p.Anchored or p.AssemblyMass>C.Heavy) then return true end end end local o=cam.CFrame.Position for _,pt in {h.Position-h.UpVector*1.7,hd.Position,hd.Position+hd.LookVector*1.05} do if (pt-o).Magnitude>.1 and workspace:Raycast(o,pt-o,tr) then return true end end return false end local function mkTool() local t=Instance.new("Tool") t.Name="Hammer" t.CanBeDropped=false local h,hd=parts() hd.CFrame=h.CFrame*CFrame.new(0,2.1,0) hd.Massless=true local w=Instance.new("WeldConstraint") w.Part0,w.Part1=h,hd w.Parent=hd h.Parent=t hd.Parent=t local eq,sw,st,ct,cpos,last,vh,vd=false,false,false,false,nil,0 local ps,rs,sh=spr(50,9,V3(1.4,-1.5,-2.2)),spr(50,9,V3(-.17,.26,-.17)),spr(120,10,Vector3.zero) local bt,sp,sr,bp=0,ps.pos,rs.pos,false local lhp,aimed,pw=nil,false,1 local poses={idle={V3(1.4,-1.5,-2.2),V3(-10,15,-10),50,9},windup={V3(1.7,-.7,-1.4),V3(60,10,-15),60,9},strike={V3(.5,-1.4,-3.2),V3(-125,-5,0),260,15}} local function pose(n) local p=poses[n] ps.target=p[1] rs.target=p[2]*(math.pi/180) ps.k,ps.d,rs.k,rs.d=p[3],p[4],p[3],p[4] end local function resolve(dt) local np,nr=ps.pos,rs.pos local _,hn=poseCFs(np,nr) local spd=lhp and (hn.Position-lhp).Magnitude/dt or 0 if not collides(poseCFs(np,nr)) then sp,sr,bp=np,nr,false return end local rp,rr if not collides(poseCFs(sp,sr)) then local lo,hi=0,1 for _=1,7 do local m=(lo+hi)/2 if collides(poseCFs(sp:Lerp(np,m),sr:Lerp(nr,m))) then hi=m else lo=m end end rp,rr=sp:Lerp(np,lo),sr:Lerp(nr,lo) else rr=nr for i=1,12 do rp=np+V3(0,0,i*.2) if not collides(poseCFs(rp,nr)) then break end end end ps.pos,rs.pos=rp,rr local f=bp and 0 or -C.Bounce ps.vel*=f rs.vel*=f bp=true sp,sr=rp,rr if st and not ct and spd>=C.MinSpeed then ct=true local _,hc=poseCFs(rp,rr) cpos=hc.Position pw=math.clamp(spd/40,.7,1.5) end end local function swing() if not eq or sw or os.clock()-last.1 and n.Unit or V3(1,0,0) local rx,ry,rz=CFrame.fromMatrix(Vector3.zero,n,d,n:Cross(d)):ToEulerAnglesXYZ() ps.target=G+d*math.clamp(to.Magnitude-3.3,0,3.2) rs.target=V3(rx,ry,rz) ct,cpos,st=false,nil,true local t0=os.clock() while eq and not ct and os.clock()-t0<.45 do RS.Heartbeat:Wait() end st=false local ok=false if eq then if ct then ok=hit(cpos,pw) elseif aimed then ok=hit(nil,1) end end if ok then sh.vel+=V3(-1,(math.random()-.5)*.6,0) rs.vel+=V3(3,0,0) end task.wait(.25) pose("idle") task.wait(.2) sw=false end local function render(dt) dt=math.min(dt,1/20) upd(sh,dt) cam.CFrame*=CFrame.Angles(sh.pos.X,sh.pos.Y,sh.pos.Z) local md=UIS:GetMouseDelta() rs.vel+=V3(md.Y*.04,md.X*.04,-md.X*.03) local root=plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") local spd=root and (root.AssemblyLinearVelocity*V3(1,0,1)).Magnitude or 0 bt+=dt*spd*.45 local bob=V3(math.cos(bt)*.04,math.abs(math.sin(bt))*.05,0)*math.clamp(spd/16,0,1) upd(ps,dt) upd(rs,dt) resolve(dt) local r=rs.pos vh.CFrame=cam.CFrame*CFrame.new(ps.pos+bob)*CFrame.Angles(r.X,r.Y,r.Z)*CFrame.new(0,1.2,0) vd.CFrame=vh.CFrame*CFrame.new(0,2.1,0) lhp=vd.CFrame.Position end local function cleanup() if not eq then return end eq,sw,st=false,false,false pcall(function() RS:UnbindFromRenderStep("HammerView") end) if vh then vh:Destroy() vh=nil end if vd then vd:Destroy() vd=nil end h.Transparency=0 hd.Transparency=0 plr.CameraMode=Enum.CameraMode.Classic end t.Equipped:Connect(function() eq=true plr.CameraMode=Enum.CameraMode.LockFirstPerson h.Transparency=1 hd.Transparency=1 vh,vd=parts() for _,p in {vh,vd} do p.Anchored=true p.CastShadow=false p.Parent=cam end cp.FilterDescendantsInstances={plr.Character,cam} pose("idle") ps.pos,rs.pos=poses.idle[1],poses.idle[2]*(math.pi/180) ps.vel,rs.vel=Vector3.zero,Vector3.zero sp,sr,bp=ps.pos,rs.pos,false local _,hh=poseCFs(ps.pos,rs.pos) lhp=hh.Position RS:BindToRenderStep("HammerView",Enum.RenderPriority.Camera.Value+1,render) end) t.Unequipped:Connect(cleanup) t.Destroying:Connect(cleanup) t.Activated:Connect(swing) return t end local function mkReset() local t=Instance.new("Tool") t.Name="Reset Destruction" t.ToolTip="Click to restore everything you destroyed" t.CanBeDropped=false t.RequiresHandle=false t.Activated:Connect(resetAll) return t end local function give() local bp=plr:WaitForChild("Backpack") if not bp:FindFirstChild("Hammer") then mkTool().Parent=bp end if not bp:FindFirstChild("Reset Destruction") then mkReset().Parent=bp end end plr.CharacterAdded:Connect(function() task.wait(.5) give() end) if plr.Character then give() end