Advertisement
wulfbawg

[ROBLOX] - Wulfbug9's Scythe

Jul 20th, 2014
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.63 KB | None | 0 0
  1. -- > Dumb scythe by wulfbug9.
  2. -- > Released cause I never finished, nor will.
  3. -- > Enjoy.
  4.  
  5. ------------------------------------------------------------------------ useful functions
  6. function r(n) return (math.random()-.5)*2*n end
  7. function c(func,args) coroutine.resume(coroutine.create(func),unpack(args or {})) end
  8. function Part(Name,Parent,Size,CFrame,Color,Trans,Anch,Can,Mat)
  9.     local surfaces = {"Front","Back","Left","Right","Top","Bottom"}
  10.     local p = Instance.new("Part",Parent)p.Name = Name
  11.     p.FormFactor = "Custom"p.Size = Size
  12.     p.Anchored = Anch p.CFrame = CFrame
  13.     p.BrickColor = BrickColor.new(Color)p.Transparency = Trans
  14.     p.CanCollide = Can;p.Material = Mat
  15.     p:BreakJoints();p.Locked = true
  16.     for i=1,#surfaces do p[surfaces[i].."Surface"] = 10 end
  17.     return p
  18. end
  19. function WedgePart(Name,Parent,Size,CFrame,Color,Trans,Anch,Can,Mat)
  20.     local surfaces = {"Front","Back","Left","Right","Top","Bottom"}
  21.     local p = Instance.new("WedgePart",Parent)p.Name = Name
  22.     p.FormFactor = "Custom"p.Size = Size
  23.     p.Anchored = Anch p.CFrame = CFrame
  24.     p.BrickColor = BrickColor.new(Color)p.Transparency = Trans
  25.     p.CanCollide = Can;p.Material = Mat
  26.     p:BreakJoints();p.Locked = true
  27.     for i=1,#surfaces do p[surfaces[i].."Surface"] = 10 end
  28.     return p
  29. end
  30. function Mesh(Parent,Type,Scale,ID,TID)
  31.     local m = Instance.new("SpecialMesh",Parent)m.MeshType = Type
  32.     m.Scale = Scale or Vector3.new(1,1,1)
  33.     if ID then m.MeshId = ID end if TID then m.TextureId = TID end
  34.     return m
  35. end
  36. function Weld(p1,p2,c0,c1)
  37.     local w = Instance.new("Weld",p1)w.Part0 = p1;w.Part1 = p2
  38.     w.C0,w.C1 = c0 or CFrame.new(),c1 or CFrame.new()
  39.     return w
  40. end
  41. function rayCast(pos,dir,ign)
  42.     ign = ign or {char}
  43.     return workspace:FindPartOnRayWithIgnoreList(Ray.new(pos,dir),ign)
  44. end
  45. ------------------------------------------------------------------------
  46. Tween = {}
  47. function slerp(a,b,c)return (1-c)*a+(c*b)end
  48. function cslerp(start,destination,increment)
  49.     local c1 = {start.X,start.Y,start.Z,start:toEulerAnglesXYZ()}
  50.     local c2 = {destination.X,destination.Y,destination.Z,destination:toEulerAnglesXYZ()}
  51.     for i,v in pairs(c1)do c1[i] = slerp(v,c2[i],increment)end
  52.     return CFrame.new(c1[1],c1[2],c1[3])*CFrame.Angles(c1[4],c1[5],c1[6])
  53. end
  54. function TweenWeld(weld,type,start,finish,speed,sync)
  55.     if Tween[weld] and Tween[weld][1] == true then return end
  56.     Tween[weld] = {weld,true}
  57.     local function T()
  58.         for i=1,speed do
  59.             local s = i/speed
  60.             weld[type] = cslerp(start,finish,s)
  61.             game:service("RunService").Stepped:wait()
  62.         end
  63.         Tween[weld] = {weld,false}
  64.     end
  65.     if sync then coroutine.wrap(T)() else T() end
  66. end
  67. ------------------------------------------------------------------------ variables
  68. player = game:service("Players").LocalPlayer
  69. local char
  70. repeat wait() char = player.Character until char
  71. root = char:WaitForChild("HumanoidRootPart")
  72. torso = char:WaitForChild("Torso")
  73. humanoid = char:WaitForChild("Humanoid")
  74. head = char:WaitForChild("Head")
  75. bodycolours = char:WaitForChild("Body Colors")
  76. mouse = player:GetMouse()
  77. step = game:service("RunService").RenderStepped
  78. camera = workspace.CurrentCamera
  79. asset = "http://www.roblox.com/asset/?id="
  80. meshes = {["blast"] = 20329976,["ring"] = 3270017,["spike"] = 1033714,["cone"] = 1082802,["crown"] = 20329976,["cloud"] = 1095708,["diamond"] = 9756362}
  81. sounds = {["explode"] = 130792180;["spin"] = 147722227;["patrick"] = 135290668}
  82. Attacking = false
  83. Trailing = true
  84. Spin = false
  85. target = nil
  86. Rad = 0
  87. c0 = {
  88.     ls = CFrame.new(-1,0.5,0)*CFrame.Angles(math.pi/4,0,0),
  89.     rs = CFrame.new(1,0.5,0)*CFrame.Angles(math.pi/3,0,0),
  90.     lh = CFrame.new(-1,-1,0),
  91.     rh = CFrame.new(1,-1,0),
  92.     nk = CFrame.new(0,1,0),
  93.     tw = CFrame.new(0,0,0),
  94. }
  95. c0NA = {
  96.     ls = CFrame.new(-1,0.5,0),
  97.     rs = CFrame.new(1,0.5,0),
  98.     lh = CFrame.new(-1,-1,0),
  99.     rh = CFrame.new(1,-1,0),
  100.     nk = CFrame.new(0,1,0),
  101.     tw = CFrame.new(0,0,0),
  102. }
  103. c1 = {
  104.     ls = CFrame.new(0.5,0.5,0),
  105.     rs = CFrame.new(-0.5,0.5,0),
  106.     lh = CFrame.new(-.5,1,0),
  107.     rh = CFrame.new(.5,1,0),
  108.     nk = CFrame.new(0,-.5,0),
  109.     tw = CFrame.new(0,0,0),
  110. }
  111. bg = Instance.new("BodyGyro",root)
  112. bg.maxTorque = Vector3.new(1,1,1)*10^6
  113. bg.P = 10^4
  114. rs = Weld(torso,char:WaitForChild("Right Arm"),c0.rs,c1.rs)
  115. ls = Weld(torso,char:WaitForChild("Left Arm"),c0.ls,c1.ls)
  116. tw = Weld(root,torso,c0.tw)
  117. hw = Weld(torso,head,c0.nk,c1.nk)
  118. colours = {"Brown","Black","Dark stone grey","White","Bright red"}
  119. local model,ohw
  120. ------------------------------------------------------------------------ effects & functions
  121. function quickSound(id,v,p)
  122.     local s = Instance.new("Sound",workspace)
  123.     s.SoundId = id
  124.     s.PlayOnRemove = true
  125.     s.Volume = v or 1
  126.     s.Pitch = p or 1
  127.     delay(0.025,function()s:remove()end)
  128. end
  129. function doDmg(cf,hum,dmg)
  130.     for i=1,math.random(2,3)do
  131.         local cfz = cf*CFrame.new(r(2),-2.9,r(2))
  132.         local p = Part("Blood",workspace,Vector3.new(0,0,0),cfz,"Bright red",0,true,false,"SmoothPlastic")
  133.         local m = Instance.new("CylinderMesh",p)
  134.         m.Scale = Vector3.new(0,.1,0)
  135.         c(function(pa,ma)
  136.             for i=1,math.random(10,20)do
  137.                 ma.Scale = ma.Scale + Vector3.new(.75,0,.75)
  138.                 wait()
  139.             end
  140.             wait(math.random(1,3))
  141.             for i=0,1,.1 do
  142.                 wait()
  143.                 pa.Transparency = i
  144.             end
  145.             pa:Destroy()
  146.         end,{p,m})
  147.     end
  148.     hum.Health = hum.Health - dmg
  149. end
  150. function checkDmgArea(origin,dmg,d)
  151.     for i,v in pairs(workspace:children())do
  152.         if v~=char and v:FindFirstChild("Torso") then
  153.             local h;
  154.             for _,k in pairs(v:children())do if k:IsA("Humanoid") then h = k end end
  155.             local dist = (origin.p - v:FindFirstChild("Torso").CFrame.p).magnitude
  156.             if dist < d and h~=nil then
  157.                 doDmg(v:FindFirstChild("Torso").CFrame,h,dmg)
  158.             end
  159.         end
  160.     end
  161. end
  162. function findClosestPlayer(origin,d)
  163.     local bdist,plr = d,nil
  164.     for i,v in pairs(workspace:children())do
  165.         if v~=char and v:FindFirstChild("Torso") then
  166.             local h;
  167.             for _,k in pairs(v:children())do if k:IsA("Humanoid") then h = k end end
  168.             local dist = (origin.p - v:FindFirstChild("Torso").CFrame.p).magnitude
  169.             if dist < bdist and h~=nil and h.Health~=0 then
  170.                 bdist,plr = dist,v
  171.             end
  172.         end
  173.     end
  174.     return plr,bdist
  175. end
  176. function drawLine(mag,one,two)
  177.     local t = Part("",char,Vector3.new(.5,mag,.5),CFrame.new(one,two)*CFrame.new(0,0,-mag/2)*CFrame.Angles(math.pi/2,0,0),"White",0,true,false,"Plastic")
  178.     c(function(p,m)
  179.         for i=1,0,-.05 do
  180.             m.Scale = Vector3.new(i,1,i)
  181.             wait(1/30)
  182.         end
  183.         p:Destroy()
  184.     end,{t,Instance.new("CylinderMesh",t)})
  185. end
  186. function Trail(part)
  187.     Trailing = true
  188.     local lastPos = part.CFrame.p
  189.     local tik = tick()
  190.     local tim = .025
  191.     local loop;
  192.     loop = game:service("RunService").RenderStepped:connect(function()
  193.         if (tick()-tik)>tim and Trailing then
  194.             local dist = (lastPos-part.CFrame.p).magnitude
  195.             drawLine(dist,lastPos,part.CFrame.p)
  196.             lastPos = part.CFrame.p
  197.             tik = tick()
  198.         elseif not Trailing then
  199.             loop:disconnect()
  200.         end
  201.     end)
  202. end
  203. function modelCloneTrail(model)
  204.     for i,v in pairs(model:children())do
  205.         if v:IsA("BasePart") then
  206.             local p = v:Clone()
  207.             p.Anchored = true
  208.             p.Parent = workspace
  209.             c(function(part)
  210.                 for i=0,1,.2 do
  211.                     part.Transparency = i
  212.                     wait(1/30)
  213.                 end
  214.                 part:Destroy()
  215.             end,{p})
  216.         end
  217.     end
  218. end
  219. ------------------------------------------------------------------------ build the weapon
  220. pcall(function()char:FindFirstChild("DScythe"):Destroy()end)
  221. model = Instance.new("Model",char)
  222. model.Name = "DScythe"
  223. blademodel = Instance.new("Model",model)
  224. blademodel.Name = "bladeModel"
  225. handle = Part("",model,Vector3.new(.3,7.5,.3),torso.CFrame,colours[1],0,false,false,"Plastic")
  226. handlem = Instance.new("CylinderMesh",handle)
  227. handlew = Weld(char:FindFirstChild("Right Arm"),handle,CFrame.new(-3.25,-1.1,0)*CFrame.Angles(-math.pi/2.5,0,math.pi/2))
  228. l1 = Part("",model,Vector3.new(0,7.55,0),torso.CFrame,colours[3],0,false,false,"Plastic")
  229. l1m = Mesh(l1,"Brick",Vector3.new(.2,1,1.5))
  230. l1w = Weld(handle,l1)
  231. l2 = Part("",model,Vector3.new(0,7.55,0),torso.CFrame,colours[3],0,false,false,"Plastic")
  232. l2m = Mesh(l2,"Brick",Vector3.new(1.5,1,.2))
  233. l2w = Weld(handle,l2)
  234. l3 = Part("",model,Vector3.new(0,7.55,0),torso.CFrame,colours[2],0,false,false,"Plastic")
  235. l3m = Mesh(l3,"Brick",Vector3.new(.2,1,1.5))
  236. l3w = Weld(handle,l3,CFrame.Angles(0,math.pi/4,0))
  237. l4 = Part("",model,Vector3.new(0,7.55,0),torso.CFrame,colours[2],0,false,false,"Plastic")
  238. l4m = Mesh(l4,"Brick",Vector3.new(.2,1,1.5))
  239. l4w = Weld(handle,l4,CFrame.Angles(0,-math.pi/4,0))
  240. p1 = Part("",model,Vector3.new(0,0,0),torso.CFrame,colours[2],0,false,false,"Plastic")
  241. p1m = Instance.new("CylinderMesh",p1)
  242. p1m.Scale = Vector3.new(1.55,1,1.55)
  243. p1w = Weld(handle,p1,CFrame.new(0,2,0))
  244. p2 = Part("",model,Vector3.new(0,0,0),torso.CFrame,colours[3],0,false,false,"Plastic")
  245. p2m = Instance.new("CylinderMesh",p2)
  246. p2m.Scale = Vector3.new(1.55,1,1.55)
  247. p2w = Weld(handle,p2,CFrame.new(0,1.5,0))
  248. p3 = Part("",model,Vector3.new(0,0,0),torso.CFrame,colours[2],0,false,false,"Plastic")
  249. p3m = Instance.new("CylinderMesh",p3)
  250. p3m.Scale = Vector3.new(1.55,1,1.55)
  251. p3w = Weld(handle,p3,CFrame.new(0,1,0))
  252. p4 = Part("",model,Vector3.new(0,0,0),torso.CFrame,colours[3],0,false,false,"Plastic")
  253. p4m = Instance.new("CylinderMesh",p4)
  254. p4m.Scale = Vector3.new(1.55,1,1.55)
  255. p4w = Weld(handle,p4,CFrame.new(0,.5,0))
  256. p5 = Part("",model,Vector3.new(0,0,0),torso.CFrame,colours[2],0,false,false,"Plastic")
  257. p5m = Instance.new("CylinderMesh",p5)
  258. p5m.Scale = Vector3.new(1.55,1,1.55)
  259. p5w = Weld(handle,p5)
  260. p6 = Part("",model,Vector3.new(0,0,0),torso.CFrame,colours[3],0,false,false,"Plastic")
  261. p6m = Instance.new("CylinderMesh",p6)
  262. p6m.Scale = Vector3.new(1.55,1,1.55)
  263. p6w = Weld(handle,p6,CFrame.new(0,-.5,0))
  264. p7 = Part("",model,Vector3.new(0,0,0),torso.CFrame,colours[2],0,false,false,"Plastic")
  265. p7m = Instance.new("CylinderMesh",p7)
  266. p7m.Scale = Vector3.new(1.55,1,1.55)
  267. p7w = Weld(p4,p7,CFrame.new(0,-1,0))
  268. p8 = Part("",model,Vector3.new(0,0,0),torso.CFrame,colours[3],0,false,false,"Plastic")
  269. p8m = Instance.new("CylinderMesh",p8)
  270. p8m.Scale = Vector3.new(1.55,1,1.55)
  271. p8w = Weld(p3,p8,CFrame.new(0,-1.5,0))
  272. p9 = Part("",model,Vector3.new(.4,1.25,.4),torso.CFrame,colours[2],0,false,false,"Plastic")
  273. p9m = Instance.new("CylinderMesh",p9)
  274. p9w = Weld(handle,p9,CFrame.new(0,3.85,0))
  275. p10 = Part("",model,Vector3.new(.35,1.25,.35),torso.CFrame,colours[3],0,false,false,"Plastic")
  276. p10m = Instance.new("CylinderMesh",p10)
  277. p10w = Weld(p9,p10,CFrame.new(0,.025,0))
  278. p11 = Part("",blademodel,Vector3.new(0,.75,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic") --<
  279. p11m = Mesh(p11,"Brick",Vector3.new(.25,1,2))
  280. p11w = Weld(p10,p11,CFrame.new(0,-.125,-1))
  281. p12 = WedgePart("",blademodel,Vector3.new(0,.25,2),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  282. p12m = Mesh(p12,"Wedge",Vector3.new(.25,1,1))
  283. p12w = Weld(p11,p12,CFrame.new(0,.5,0))
  284. p13 = WedgePart("",blademodel,Vector3.new(0,.25,2),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  285. p13m = Mesh(p13,"Wedge",Vector3.new(.25,1,1))
  286. p13w = Weld(p11,p13,CFrame.new(0,-.5,0)*CFrame.Angles(math.pi,0,0))
  287. p14 = Part("",blademodel,Vector3.new(0,.75,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  288. p14m = Mesh(p14,"Brick",Vector3.new(.25,1,1))
  289. p14w = Weld(p11,p14,CFrame.new(0,-.25,-1.5))
  290. p15 = WedgePart("",blademodel,Vector3.new(0,.5,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  291. p15m = Mesh(p15,"Wedge",Vector3.new(.25,1,1))
  292. p15w = Weld(p14,p15,CFrame.new(0,-.625,0)*CFrame.Angles(math.pi,0,0))
  293. p16 = WedgePart("",blademodel,Vector3.new(0,.25,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  294. p16m = Mesh(p16,"Wedge",Vector3.new(.25,1,1))
  295. p16w = Weld(p14,p16,CFrame.new(0,.5,0))
  296. p17 = Part("",blademodel,Vector3.new(0,.75,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  297. p17m = Mesh(p17,"Brick",Vector3.new(.25,1,1))
  298. p17w = Weld(p14,p17,CFrame.new(0,-.5,-1))
  299. p18 = WedgePart("",blademodel,Vector3.new(0,.5,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  300. p18m = Mesh(p18,"Wedge",Vector3.new(.25,1,1))
  301. p18w = Weld(p17,p18,CFrame.new(0,-.625,0)*CFrame.Angles(math.pi,0,0))
  302. p19 = WedgePart("",blademodel,Vector3.new(0,.5,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  303. p19m = Mesh(p19,"Wedge",Vector3.new(.25,1,1))
  304. p19w = Weld(p17,p19,CFrame.new(0,.625,0))
  305. p20 = Part("",blademodel,Vector3.new(0,.5,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  306. p20m = Mesh(p20,"Brick",Vector3.new(.25,1,1))
  307. p20w = Weld(p17,p20,CFrame.new(0,-.625,-1))
  308. p21 = WedgePart("",blademodel,Vector3.new(0,.75,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  309. p21m = Mesh(p21,"Wedge",Vector3.new(.25,1,1))
  310. p21w = Weld(p20,p21,CFrame.new(0,-.625,0)*CFrame.Angles(math.pi,0,0))
  311. p22 = WedgePart("",blademodel,Vector3.new(0,.75,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  312. p22m = Mesh(p22,"Wedge",Vector3.new(.25,1,1))
  313. p22w = Weld(p20,p22,CFrame.new(0,.625,0))
  314. p23 = WedgePart("",blademodel,Vector3.new(0,1.25,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  315. p23m = Mesh(p23,"Wedge",Vector3.new(.25,1,1))
  316. p23w = Weld(p20,p23,CFrame.new(0,-.375,-1))
  317. p24 = WedgePart("",blademodel,Vector3.new(0,1.25,1),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  318. p24m = Mesh(p24,"Wedge",Vector3.new(.25,1,1))
  319. p24w = Weld(p23,p24,CFrame.new(0,-1.25,0)*CFrame.Angles(math.pi,0,0))
  320. p25 = Part("",blademodel,Vector3.new(.25,1,1),torso.CFrame,colours[5],0,false,false,"SmoothPlastic")
  321. p25m = Mesh(p25,"Sphere",Vector3.new(.4,1,1))
  322. p25w = Weld(p11,p25)
  323. p26 = Part("",blademodel,Vector3.new(.25,.5,.5),torso.CFrame,colours[4],0,false,false,"SmoothPlastic")
  324. p26m = Mesh(p26,"Sphere",Vector3.new(.5,1,1))
  325. p26w = Weld(p25,p26)
  326. p27 = Part("",blademodel,Vector3.new(.25,.2,.2),torso.CFrame,colours[2],0,false,false,"SmoothPlastic")
  327. p27m = Mesh(p27,"Sphere",Vector3.new(.6,1,1))
  328. p27w = Weld(p25,p27)
  329. ohw = handlew.C0
  330. ohwNA = CFrame.new(0,-1.1,0)
  331. ------------------------------------------------------------------------ functions + attacks
  332. function returnToOriginal(speed)
  333.     ----- reset some settings
  334.         Rad = 0
  335.         target = nil
  336.     -----
  337.     TweenWeld(rs,"C0",rs.C0,c0.rs,speed,true)
  338.     TweenWeld(ls,"C0",ls.C0,c0.ls,speed,true)
  339.     TweenWeld(tw,"C0",tw.C0,c0.tw,speed,true)
  340.     TweenWeld(hw,"C0",hw.C0,c0.nk,speed,true)
  341.     TweenWeld(handlew,"C0",handlew.C0,ohw,speed)
  342. end
  343. function stab(victim)
  344.     local t = victim:FindFirstChild("Torso")
  345.     target = t
  346.     checkDmgArea(t.CFrame,20,3)
  347. end
  348. function swing()
  349.     Attacking = true
  350.     Spin = true
  351.     TweenWeld(rs,"C0",rs.C0,c0NA.rs*CFrame.new(.5,0,-.5)*CFrame.Angles(math.pi/2,0,math.pi/2),5,true)
  352.     TweenWeld(ls,"C0",ls.C0,c0NA.ls*CFrame.Angles(0,0,-math.pi/8),5,true)
  353.     TweenWeld(tw,"C0",tw.C0,c0.tw,5,true)
  354.     TweenWeld(hw,"C0",hw.C0,c0.nk,5,true)
  355.     TweenWeld(handlew,"C0",handlew.C0,ohwNA*CFrame.new(0,-2.5,0)*CFrame.Angles(math.pi,math.pi/2,0),5)
  356.     local victim
  357.     repeat wait()
  358.         modelCloneTrail(blademodel)
  359.         victim = findClosestPlayer(p24.CFrame,2)
  360.     until Rad >= 360*2 or victim~=nil
  361.     Spin = false
  362.     if victim then
  363.         Rad = 0
  364.         stab(victim)
  365.     end
  366.     returnToOriginal(10)
  367.     Attacking = false
  368. end
  369. ------------------------------------------------------------------------
  370. mouse.Button1Down:connect(function()
  371. end)
  372. mouse.KeyDown:connect(function(key)
  373.     key:lower()
  374.     if key=="q" and not Attacking then
  375.         swing()
  376.     end
  377. end)
  378. ------------------------------------------------------------------------
  379. step:connect(function()
  380.     if target and not Spin then
  381.         bg.cframe = CFrame.new(CFrame.new(root.CFrame.x,root.CFrame.y,root.CFrame.z).p,CFrame.new(target.CFrame.x,root.CFrame.y,target.CFrame.z).p)
  382.     elseif not target and not Spin then
  383.         bg.cframe = CFrame.new(CFrame.new(root.CFrame.x,root.CFrame.y,root.CFrame.z).p,CFrame.new(camera.CoordinateFrame.x,root.CFrame.y,camera.CoordinateFrame.z).p)*CFrame.Angles(0,math.pi,0)
  384.     elseif Spin then
  385.         Rad = Rad + 10
  386.         bg.cframe = CFrame.new(root.CFrame.x,root.CFrame.y,root.CFrame.z)*CFrame.Angles(0,math.rad(Rad),0)
  387.     end
  388. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement