Advertisement
JuicyPenguin

Martin Garrix Dubstep gun script

May 5th, 2015
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function clerp(c1,c2,al)
  2.     local com1 = {c1.X,c1.Y,c1.Z,c1:toEulerAnglesXYZ()}
  3.     local com2 = {c2.X,c2.Y,c2.Z,c2:toEulerAnglesXYZ()}
  4.     for i,v in pairs(com1) do
  5.         com1[i] = v+(com2[i]-v)*al
  6.     end
  7.     return CFrame.new(com1[1],com1[2],com1[3]) * CFrame.Angles(select(4,unpack(com1)))
  8. end
  9.  
  10. plr = game:service'Players'.LocalPlayer
  11. char = plr.Character
  12. mouse = plr:GetMouse()
  13. humanoid = char:findFirstChild("Humanoid")
  14. torso = char:findFirstChild("Torso")
  15. head = char.Head
  16. ra = char:findFirstChild("Right Arm")
  17. la = char:findFirstChild("Left Arm")
  18. rl = char:findFirstChild("Right Leg")
  19. ll = char:findFirstChild("Left Leg")
  20. rs = torso:findFirstChild("Right Shoulder")
  21. ls = torso:findFirstChild("Left Shoulder")
  22. rh = torso:findFirstChild("Right Hip")
  23. lh = torso:findFirstChild("Left Hip")
  24. neck = torso:findFirstChild("Neck")
  25. rj = char:findFirstChild("HumanoidRootPart"):findFirstChild("RootJoint")
  26. anim = char:findFirstChild("Animate")
  27. do --Removing ROBLOX's new Looped bug >_>
  28.             local function rec(x)
  29.                 for i,v in pairs(x:children()) do
  30.                     if v:IsA'Animation' then
  31.                         v.AnimationId = 'rbxassetid://30196114'
  32.                     end
  33.                     rec(v)
  34.                 end
  35.             end
  36.             rec(anim) --the Animate script
  37.         end
  38.  
  39.         humanoid.Jump = true
  40.  
  41.         wait(.4)
  42.  
  43.  
  44.         if anim then
  45.         anim:Destroy()
  46.         end
  47. rootpart = char:findFirstChild("HumanoidRootPart")
  48. camera = workspace.CurrentCamera
  49. modelforparts = char:findFirstChild("ModelForParts") or Instance.new("Model", char)
  50. modelforparts.Name = "ModelForParts"
  51.  
  52. function trailconnect(obj, wat)
  53. local trail = {}
  54. for i = 1, 4 do
  55. local p = Instance.new("Part")
  56. p.BrickColor = obj.BrickColor
  57. p.formFactor = "Custom"
  58. p.Size = Vector3.new(1,1,1)
  59. p.Locked = true
  60. p.Anchored = true
  61. p.CanCollide = false
  62. local mesh = Instance.new("CylinderMesh", p)
  63. mesh.Name = "Mesh"
  64. table.insert(trail,{p,0})
  65. end
  66. local lastpos = obj.Position
  67. local updatethis = 0
  68. local dontdothis = false
  69. game:service'RunService'.Stepped:connect(function()
  70.     if wat == true then if dontdothis then return end
  71.         for i,v in pairs(trail) do
  72.         game:service'Debris':AddItem(obj, 0)
  73.         table.remove(v, i)
  74.         end
  75.         dontdothis = true
  76.         return
  77.     end
  78. updatethis = ((updatethis) % 4) + 1
  79. local dstnc = (obj.Position - lastpos).magnitude
  80. trail[updatethis][1].Mesh.Scale = Vector3.new(.2,dstnc,.2)
  81. trail[updatethis][1].Parent = obj.Parent
  82. trail[updatethis][1].CFrame = CFrame.new((obj.Position + lastpos)/2,obj.Position) * CFrame.Angles(math.pi/2, 0, 0)
  83. trail[updatethis][2] = 0
  84. for i,v in pairs(trail) do
  85. v[2] = v[2] + .15
  86. v[1].Transparency = v[2]
  87. end
  88. lastpos = obj.Position
  89. end)
  90. end
  91.  
  92. do --rayCast
  93.     function rayCast(startpos, Speed, Gravity, Dmg, color)
  94.         local ran,err = ypcall(function()
  95.     local rayPart         = Instance.new("Part")
  96.     rayPart.Name          = "RayPart"
  97.     rayPart.BrickColor    = BrickColor.new(color)
  98.     rayPart.Anchored      = true
  99.     rayPart.CanCollide    = false
  100.     rayPart.Locked        = true
  101.     rayPart.FormFactor    = "Custom"
  102.     rayPart.TopSurface    = Enum.SurfaceType.Smooth
  103.     rayPart.BottomSurface = Enum.SurfaceType.Smooth
  104.     rayPart.Size          = Vector3.new(.2, 50, .2)
  105.     rayPart:breakJoints()
  106.     Instance.new("CylinderMesh", rayPart)
  107.     local fire = Instance.new("Fire", rayPart)
  108.     fire.Color = rayPart.BrickColor.Color
  109.     fire.SecondaryColor = rayPart.BrickColor.Color
  110.     fire.Heat = 0
  111.     fire.Size = 10
  112.     local pl = Instance.new("PointLight", rayPart)
  113.     pl.Color = Color3.new(rayPart.BrickColor.r/1.5, rayPart.BrickColor.g/1.5, rayPart.BrickColor.b/1.5)
  114.     pl.Range = 18
  115.  
  116.     local hitobj = false
  117.     local bulletposition = startpos.Position
  118.     rayPart.CFrame = startpos.CFrame
  119.     trailconnect(rayPart, hitobj)
  120.  
  121.    local bulletvelocity = (Vector3.new(math.random(-2,2), math.random(-2,2), math.random(-2,2)))+( mouse.Hit.p - bulletposition).unit*Speed
  122.     local bulletlastposition = bulletposition
  123.    
  124.     coroutine.resume(coroutine.create(function()
  125.         while true do
  126.  
  127.             local dt = wait()
  128.             bulletlastposition = bulletposition
  129.             bulletvelocity = bulletvelocity + (Vector3.new(0, -3.81*Gravity, 0)*dt)
  130.             bulletposition = bulletposition + (bulletvelocity*dt)
  131.             local ray = Ray.new(bulletlastposition,  (bulletposition - bulletlastposition))
  132.             local hit, hitposition = workspace:FindPartOnRayWithIgnoreList( ray, {char, modelforparts} )
  133.                
  134.     if (torso.Position - rayPart.Position).magnitude > 840 then
  135.         rayPart:Destroy()
  136.         hitobj = true
  137.      break
  138.     end
  139.  
  140.    
  141.             if hit then
  142.                 hitobj = true
  143.                     local damage = math.random(Dmg, Dmg+6)
  144.                 if hit.Parent:findFirstChild("Humanoid") ~= nil then
  145.                     hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
  146.                 elseif hit.Parent:IsA("Hat") and hit.Parent.Parent:findFirstChild("Humanoid") then
  147.                     hit.Parent.Parent.Humanoid.Health = hit.Parent.Parent.Humanoid.Health - damage
  148.                 end
  149.                 local boom = Instance.new("Part", modelforparts)
  150.                 boom.BrickColor = rayPart.BrickColor
  151.                 boom.Anchored = true
  152.                 boom.FormFactor = "Custom"
  153.                 boom.Size = Vector3.new(1,1,1)
  154.                 boom.CanCollide = false
  155.                 boom.Transparency = 0.25
  156.                 boom.CFrame = CFrame.new(hitposition.x, hitposition.y, hitposition.z)
  157.                 boom.TopSurface = 0
  158.                 boom.BottomSurface = 0
  159.                 local sphere = Instance.new("SpecialMesh", boom)
  160.                 sphere.MeshType = "Sphere"
  161.                 local pl = Instance.new("PointLight", boom)
  162.                 pl.Color = Color3.new(boom.BrickColor.r/1.5, boom.BrickColor.g/1.5, boom.BrickColor.b/1.5)
  163.                 pl.Range = 20
  164.                 for ye = 0, 8 do
  165.                     local lite = Instance.new("Part", boom)
  166.                     lite.FormFactor = "Custom"
  167.                     lite.Size = Vector3.new(.2, 1.5, .2)
  168.                     lite.BrickColor = boom.BrickColor
  169.                     lite.CanCollide = false
  170.                     lite.TopSurface = 0
  171.                     lite.Anchored = false
  172.                     lite.BottomSurface = 0
  173.                     lite.Position = boom.Position + Vector3.new(math.random(-10, 10), math.random(6,15), math.random(-10, 10))
  174.                 end
  175.                    
  176.                 for i = 0, 20, 2.5 do
  177.                     sphere.Scale = sphere.Scale + Vector3.new(i,i,i)
  178.                     boom.Transparency = boom.Transparency + i/60
  179.                     pl.Range = pl.Range + i/15
  180.                  wait()
  181.                 end
  182.                 boom:Destroy()
  183.             for i,v in pairs(workspace:children()) do
  184.                 if v:IsA("Model") and v:findFirstChild("Humanoid") then
  185.                     if v:findFirstChild("Head") and v:findFirstChild("Torso") then
  186.                     if (v:findFirstChild("Torso").Position - boom.Position).magnitude < 16 and v.Name ~= char.Name then
  187.                     v:findFirstChild("Humanoid"):TakeDamage(math.random(Dmg+2,Dmg+6))
  188.                     end
  189.                     end
  190.                 end
  191.                 if v and v:IsA("Part") and v.Name ~= "Base" then
  192.                     if (v.Position - boom.Position).magnitude < 16 then
  193.                     v:BreakJoints()
  194.                     v.TopSurface = 0
  195.                     v.BottomSurface = 0
  196.                     v.LeftSurface = 0
  197.                     v.RightSurface = 0
  198.                     v.FrontSurface = 0
  199.                     v.BackSurface = 0
  200.                     v.Anchored = false
  201.                     end
  202.                 end
  203.         end
  204.             pcall(function()
  205.                 bulletposition = hitposition
  206.                 rayPart.CFrame = CFrame.new(bulletposition, bulletposition+bulletvelocity) * CFrame.Angles(math.pi/2, 0, 0)
  207.                 rayPart:Destroy()
  208.             end)
  209.                 break
  210.             end
  211.             rayPart.CFrame = CFrame.new(bulletposition, bulletposition+bulletvelocity) * CFrame.Angles(math.pi/2, 0, 0)
  212.             rayPart.Parent = modelforparts
  213.         end
  214.     end))
  215.  for i = 70, 65, -1.5 do
  216.     firing = true
  217.     camera.FieldOfView = i
  218.     wait()
  219. end
  220. for i = 65, 70, 2.5 do
  221.     firing = false
  222.     camera.FieldOfView = i
  223.     wait()
  224. end
  225. end)
  226. if err then
  227.     print(err)
  228.     end
  229. end
  230. end
  231.  
  232.  
  233. charge = 100
  234.  
  235. plrgui = game:service'Players'.LocalPlayer:findFirstChild("PlayerGui")
  236.  
  237. local statusgui = Instance.new("ScreenGui", plrgui)
  238. local mainframe = Instance.new("Frame", statusgui)
  239.     mainframe.Size = UDim2.new(0, 200, 0, 200)
  240.     mainframe.Position = UDim2.new(.75, 0, .75, 0)
  241.     mainframe.Style = 3
  242.     local image = Instance.new("ImageLabel", mainframe)
  243.     image.Size = UDim2.new(1, 0, .47, 0)
  244.     image.Position = UDim2.new(0, 0, .235, 0)
  245.     image.BackgroundTransparency = 1
  246.     image.Image = "rbxassetid://145057975"
  247.     local chargetext = Instance.new("TextLabel", mainframe)
  248.     chargetext.FontSize = "Size18"
  249.     chargetext.Size = UDim2.new(1, 0, .95, 0)
  250.     chargetext.TextYAlignment = "Bottom"
  251.     chargetext.BackgroundTransparency = 1
  252.     chargetext.TextColor3 = Color3.new(1,1,1)
  253.     game:service'RunService'.Stepped:connect(function()
  254.         chargetext.Text = math.floor(charge).."%"
  255.     end)
  256.    
  257.    
  258.  
  259. local rm = Instance.new("Weld", torso)
  260. rm.C0 = CFrame.new(1.5, 0.5, 0)
  261. rm.C1 = CFrame.new(0, 0.5, 0)
  262. rm.Part0 = torso
  263. rm.Part1 = ra
  264. local lm = Instance.new("Weld", torso)
  265. lm.C0 = CFrame.new(-1.5, 0.5, 0)
  266. lm.C1 = CFrame.new(0, 0.5, 0)
  267. lm.Part0 = torso
  268. lm.Part1 = la
  269.  
  270. sound = Instance.new("Sound", head)
  271. sound.Volume = 1
  272. sound.SoundId = "rbxassetid://277956568"
  273. sound.Looped = true
  274.  
  275.  
  276. dancemode = true
  277. debounceofsprint = false
  278.  
  279. --create func
  280. function part(parent, size, color, formfactor, collide, transparency)
  281.     if transparency == nil then transparency=0 end
  282.     if collide == nil then collide=false end
  283.         if formfactor == nil then formfactor="Custom" end
  284.         local p = Instance.new("Part", parent)
  285.         p.FormFactor = formfactor
  286.         p.CanCollide = collide
  287.         p.Size = size
  288.         p.Locked = true
  289.         p.Transparency = transparency
  290.         p.Position = torso.Position + Vector3.new(0, 1, 0)
  291.         p.BrickColor = color
  292.         p.FrontSurface = "SmoothNoOutlines"
  293.         p.BackSurface = "SmoothNoOutlines"        
  294.         p.LeftSurface = "SmoothNoOutlines"
  295.         p.BottomSurface = "SmoothNoOutlines"
  296.         p.TopSurface = "SmoothNoOutlines"  
  297.         p.RightSurface = "SmoothNoOutlines"
  298.         return p
  299. end
  300. function wedge(parent, size, color, formfactor, collide, transparency)
  301.         if transparency==nil then transparency=0 end
  302.     if collide==nil then collide=false end
  303.         if formfactor==nil then formfactor="Custom" end
  304.         local p = Instance.new("WedgePart", parent)
  305.         p.FormFactor = formfactor
  306.         p.CanCollide = collide
  307.         p.Size = size
  308.         p.Locked = true
  309.         p.Position = torso.Position
  310.         p.BrickColor = color
  311.         p.FrontSurface = "SmoothNoOutlines"
  312.         p.BackSurface = "SmoothNoOutlines"        
  313.         p.LeftSurface = "SmoothNoOutlines"
  314.         p.BottomSurface = "SmoothNoOutlines"
  315.         p.TopSurface = "SmoothNoOutlines"  
  316.         p.RightSurface = "SmoothNoOutlines"
  317.         return p
  318. end
  319. function weld(part0, part1, c0, parent, c1)
  320.     if parent == nil then parent=char end
  321.     if c1 == nil then c1=CFrame.new() end
  322.  
  323.         local wel = Instance.new("Weld", parent)
  324.         wel.Part0 = part0
  325.         wel.Part1 = part1
  326.         wel.C0 = c0
  327.         wel.C1 = c1
  328.         return wel
  329. end
  330. function specialmesh(parent, meshType, scale, meshId)
  331.     if meshId==nil then meshId="" end
  332.         local mesh = Instance.new("SpecialMesh", parent)
  333.         mesh.Scale = scale
  334.         mesh.MeshType = meshType
  335.         mesh.MeshId = meshId
  336.         return mesh
  337. end
  338. ----------------------------------------------------------------------------------------------------------
  339. --function part(parent, size, color, formfactor, collide, transparency)
  340. --function weld(part0, part1, c0, parent, c1)
  341.  
  342. ----------------------------------------------------------------------------------------------------------
  343. function animatehuman(animationid, object)
  344.             local animation = object:findFirstChild("Humanoid"):LoadAnimation(animationid)
  345.             animation:Play()
  346. end
  347. local danceAnim = Instance.new("Animation", char)
  348. danceAnim.AnimationId = "http://www.roblox.com/asset/?id=130018893"
  349. danceAnim.Name = "DancingAnimation"
  350. ----------------------------------------------------------------------------------------------------------
  351. local main = Instance.new("Part", char)
  352.         main.FormFactor = "Custom"
  353.         main.CanCollide = false
  354.         main.Size = Vector3.new(.75, 1, 1.2)
  355.         main.Locked = true
  356.         main.BrickColor = BrickColor.new("Black")
  357.         main.TopSurface = 0
  358.         main.BottomSurface = 0
  359.         main.Position = torso.Position
  360.         main:BreakJoints()
  361. local weld1 = weld(main, ra, CFrame.new(), char, CFrame.new(0, -.8, -.6))
  362.     local speaker = Instance.new("Part", char)
  363.         speaker.FormFactor = "Custom"
  364.         speaker.CanCollide = false
  365.         speaker.Size = Vector3.new(1.5, .25, 1.4)
  366.         speaker.Locked = true
  367.         speaker.BrickColor = BrickColor.new("Black")
  368.         speaker.TopSurface = 0
  369.         speaker.BottomSurface = 0
  370.         speaker.Position = torso.Position
  371.         speaker:BreakJoints()
  372. local weld2 = weld(speaker, main, CFrame.new(), char, CFrame.new(-.25, -1.7, .6))
  373.         local speaker2 = Instance.new("Part", char)
  374.         speaker2.FormFactor = "Custom"
  375.         speaker2.CanCollide = false
  376.         speaker2.Size = Vector3.new(1, .25, 2)
  377.         speaker2.Locked = true
  378.         speaker2.BrickColor = BrickColor.new("Black")
  379.         speaker2.TopSurface = 0
  380.         speaker2.BottomSurface = 0
  381.         speaker2.Position = torso.Position
  382.         speaker2:BreakJoints()
  383. local weld3 = weld(speaker2, main, CFrame.new(), char, CFrame.new(0, -1.7, -.2))
  384.         local main2 = Instance.new("Part", char)
  385.         main2.FormFactor = "Custom"
  386.         main2.CanCollide = false
  387.         main2.Size = Vector3.new(.751, 1, .6)
  388.         main2.Locked = true
  389.         main2.BrickColor = BrickColor.new("Black")
  390.         main2.TopSurface = 0
  391.         main2.BottomSurface = 0
  392.         main2.Position = torso.Position
  393.         main2:BreakJoints()
  394. local weld4 = weld(main2, ra, CFrame.new(), char, CFrame.new(0, 0, -.9))
  395.     local main3 = Instance.new("Part", char)
  396.         main3.FormFactor = "Custom"
  397.         main3.CanCollide = false
  398.         main3.Size = Vector3.new(.751, 1.45, 1)
  399.         main3.Locked = true
  400.         main3.BrickColor = BrickColor.new("Black")
  401.         main3.TopSurface = 0
  402.         main3.BottomSurface = 0
  403.         main3.Position = torso.Position
  404.         main3:BreakJoints()
  405. local weld5 = weld(main3, ra, CFrame.new(), char, CFrame.new(0, -1.6, -.9))
  406.     local main4 = Instance.new("Part", char)
  407.         main4.FormFactor = "Custom"
  408.         main4.CanCollide = false
  409.         main4.Size = Vector3.new(1, .76, 1)
  410.         Instance.new("CylinderMesh", main4)
  411.         main4.Locked = true
  412.         main4.BrickColor = BrickColor.new("Black")
  413.         main4.TopSurface = 0
  414.         main4.BottomSurface = 0
  415.         main4.Position = torso.Position
  416.         main4:BreakJoints()
  417. local weld6 = weld(main4, main, CFrame.new(), char, CFrame.new(0, -.15, -.5)*CFrame.Angles(math.pi/2, 0, math.pi/2))
  418.     local speaker3 = Instance.new("Part", char)
  419.         speaker3.FormFactor = "Custom"
  420.         speaker3.CanCollide = false
  421.         speaker3.Size = Vector3.new(1.5, .5, 1.4)
  422.         speaker3.Locked = true
  423.         speaker3.BrickColor = BrickColor.new("Black")
  424.         speaker3.TopSurface = 0
  425.         speaker3.BottomSurface = 0
  426.         speaker3.Position = torso.Position
  427.         speaker3:BreakJoints()
  428. local welds1 = weld(speaker3, main, CFrame.new(), char, CFrame.new(-.25, -2.2, .6))
  429.         local speaker4 = Instance.new("Part", char)
  430.         speaker4.FormFactor = "Custom"
  431.         speaker4.CanCollide = false
  432.         speaker4.Size = Vector3.new(1, .5, 2)
  433.         speaker4.Locked = true
  434.         speaker4.BrickColor = BrickColor.new("Black")
  435.         speaker4.TopSurface = 0
  436.         speaker4.BottomSurface = 0
  437.         speaker4.Position = torso.Position
  438.         speaker4:BreakJoints()
  439. local welds2 = weld(speaker4, main, CFrame.new(), char, CFrame.new(0, -2.205, -.2))
  440.         local speaker5 = Instance.new("Part", char)
  441.         speaker5.FormFactor = "Custom"
  442.         speaker5.CanCollide = false
  443.         speaker5.Size = Vector3.new(1.4, .4, 1.3)
  444.         speaker5.Locked = true
  445.         speaker5.BrickColor = BrickColor.new("Black")
  446.         speaker5.TopSurface = 0
  447.         speaker5.BottomSurface = 0
  448.         speaker5.Position = torso.Position
  449.         speaker5:BreakJoints()
  450. local welds3 = weld(speaker5, main, CFrame.new(), char, CFrame.new(-.25, -2, .6))
  451.         local speaker6 = Instance.new("Part", char)
  452.         speaker6.FormFactor = "Custom"
  453.         speaker6.CanCollide = false
  454.         speaker6.Size = Vector3.new(.9, .4, 1.9)
  455.         speaker6.Locked = true
  456.         speaker6.BrickColor = BrickColor.new("Black")
  457.         speaker6.TopSurface = 0
  458.         speaker6.BottomSurface = 0
  459.         speaker6.Position = torso.Position
  460.         speaker6:BreakJoints()
  461. local welds4 = weld(speaker6, main, CFrame.new(), char, CFrame.new(0, -2, -.2))
  462.    
  463.         local support = Instance.new("Part", char)
  464.         support.FormFactor = "Custom"
  465.         support.CanCollide = false
  466.         support.Size = Vector3.new(.3, .4, .6)
  467.         support.Locked = true
  468.         support.BrickColor = BrickColor.new("Black")
  469.         support.TopSurface = 0
  470.         support.BottomSurface = 0
  471.         support.Position = torso.Position
  472.         support:BreakJoints()
  473. local welds5 = weld(support, main, CFrame.new(), char, CFrame.new(0, -1.5, -.4))
  474.  
  475.  
  476. debounce = false
  477.  
  478. function stopsound()
  479. if debounce then return end
  480.     if not sound.IsPlaying then return end
  481.     sound:stop()
  482.     debounce = true
  483.     local dancebro = Instance.new("StringValue", game:service'Lighting')
  484.     dancebro.Name = ('STOPDANCING'..plr.Name)
  485.     game:service'Debris':AddItem(dancebro, 1)
  486.         coroutine.wrap(function()
  487.         while not sound.IsPlaying do
  488.             if charge <= 100 then
  489.             charge = charge + .1
  490.             wait()
  491.             elseif charge > 100 then
  492.             charge = 100
  493.             break
  494.             end
  495.         end
  496.     end)()
  497.         wait(.1)
  498.     debounce = false
  499. end
  500. mouse.Button1Down:connect(function(mous)
  501.     if debounceofsprint then return end
  502.     if sound.IsPlaying then return end
  503.     if debounce then return end
  504.     sound:play()
  505.  for i = 70, 55, -.35 do
  506.      if not sound.IsPlaying then debounce = true camera.FieldOfView = 70 return end
  507.     camera.FieldOfView = i
  508.     wait()
  509. end
  510. for i = 65, 70, 2.5 do
  511.     if not sound.IsPlaying then debounce = true camera.FieldOfView = 70 return end
  512.     camera.FieldOfView = i
  513.     wait()
  514. end
  515. if debounce then debounce = false return end
  516.     if dancemode then
  517.     for i,v in pairs(workspace:children()) do
  518.         if not sound.IsPlaying then break end
  519.                 coroutine.wrap(function()
  520.                 if v:IsA("Model") and v:findFirstChild("Humanoid") and v.Name ~= char.Name and v:findFirstChild("ModelForParts") == nil and v:findFirstChild("Torso") and (v:findFirstChild("Torso").Position - head.Position).magnitude < 30 then
  521.                         danceAnimClone = danceAnim:clone()
  522.                         danceAnimClone.Parent = v
  523.                         danceAnimClone.AnimationId = "http://www.roblox.com/asset/?id=130018893"
  524.                         wait()
  525.                         NLS([[
  526.                         function animatehuman(animationid, object)
  527.                             local animation = object:findFirstChild("Humanoid"):LoadAnimation(animationid)
  528.                             animation:Play()
  529.                         end
  530.                         while wait(.5) do
  531.                         if game:service'Lighting':findFirstChild("STOPDANCING]]..plr.Name..[[") and game:service'Lighting':findFirstChild("STOPDANCING]]..plr.Name..[["):IsA("StringValue") then game:service'Debris':AddItem(script.Parent:findFirstChild("DancingAnimation"), 5) break end
  532.                         animatehuman(script.Parent:findFirstChild("DancingAnimation"), script.Parent)
  533.                         end
  534.                         ]], v)
  535.                 end
  536.                 end)()
  537.         end
  538. end
  539.     coroutine.wrap(function()
  540.         while sound.IsPlaying do
  541.             if charge <= 1 then
  542.                 if debounce then break end
  543.                 if not sound.IsPlaying then break end
  544.                     sound:stop()
  545.                     debounce = true
  546.                     chargetext.TextColor3 = Color3.new(1,0,0)
  547.                     dancebro = Instance.new("StringValue", game:service'Lighting')
  548.                     dancebro.Name = ('STOPDANCING'..plr.Name)
  549.                     game:service'Debris':AddItem(dancebro, 1)
  550.                     coroutine.wrap(function()
  551.                         repeat wait() until charge >= 10
  552.                         debounce = false
  553.                         chargetext.TextColor3 = Color3.new(1,1,1)
  554.                     end)()
  555.                     coroutine.wrap(function()
  556.                         while not sound.IsPlaying do
  557.                             if charge <= 100 then
  558.                             charge = charge + .1
  559.                             wait()
  560.                             elseif charge > 100 then
  561.                             charge = 100
  562.                             break
  563.                             end
  564.                         end
  565.                     end)()
  566.             else
  567.             charge = charge - .08
  568.             wait()
  569.             end
  570.         end
  571.     end)()
  572.     coroutine.wrap(function()
  573.         local ran,err = ypcall(function()
  574.         while sound.IsPlaying and Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude <= 20 do
  575.     if Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude >= 20 then stopsound() break end
  576.     if not sound.IsPlaying then break end
  577.     rayCast(speaker, 1250, 0, 5, "Lavender")
  578.     wait(.35)
  579.     if Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude >= 20 then stopsound() break end
  580.     if not sound.IsPlaying then break end
  581.     rayCast(speaker, 1250, 0, 5, "Pink")
  582.     wait(.95)
  583.     if Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude >= 20 then stopsound() break end
  584.     if not sound.IsPlaying then break end
  585.     rayCast(speaker, 1250, 0, 5, "Bright bluish green")
  586.     wait(.55)
  587.     if Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude >= 20 then stopsound() break end
  588.     if not sound.IsPlaying then break end
  589.     rayCast(speaker, 1250, 0, 5, "Pink")
  590.     wait(.4)
  591.     if Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude >= 20 then stopsound() break end
  592.     if not sound.IsPlaying then break end
  593.     rayCast(speaker, 1250, 0, 5, "Bright bluish green")
  594.     local pl = Instance.new("PointLight", torso)
  595.     pl.Color = Color3.new(153/255/1.25, 102/255/1.25, 204/255/1.25)
  596.     pl.Range = 30
  597.     pl.Brightness = 0.7
  598.     game:service'Debris':AddItem(pl, .3)
  599.     wait(.45)
  600.     if Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude >= 20 then stopsound() break end
  601.     if not sound.IsPlaying then break end
  602.     rayCast(speaker, 1250, 0, 5, "Lavender")
  603.     wait(.75)
  604.     end
  605.     end) if err then print(err) end
  606.     end)()
  607. end)
  608.  
  609. mouse.Button1Up:connect(function(mous)
  610.     stopsound()
  611. end)
  612. ctrl = false
  613. mouse.KeyDown:connect(function(k)
  614.     if string.byte(k) == 50 then
  615.         ctrl = true
  616.         humanoid.WalkSpeed = 8
  617.     end
  618.     if string.byte(k) == 48 then
  619.     humanoid.WalkSpeed = 28
  620.     end
  621. end)
  622.  
  623. mouse.KeyUp:connect(function(k)
  624.     if string.byte(k) == 50 then
  625.         ctrl = false
  626.         humanoid.WalkSpeed = 16
  627.     end
  628.     if string.byte(k) == 48 then
  629.     humanoid.WalkSpeed = 16
  630.         if ctrl then
  631.             humanoid.WalkSpeed = 8
  632.         end
  633.     end
  634. end)
  635.  
  636. humanoid.Died:connect(function()
  637.     deathpos = torso.Position
  638.     WorkModel = Instance.new("Model", workspace)
  639.     WorkModel.Name = " "
  640.         wait(1/60)
  641.         humanoid.Parent = nil
  642.     if torso then
  643.         local Head = char:FindFirstChild("Head")
  644.         if Head then
  645.             local Neck = Instance.new("Weld")
  646.             Neck.Name = "Neck"
  647.             Neck.Part0 = torso
  648.             Neck.Part1 = Head
  649.             Neck.C0 = CFrame.new(0, 1.5, 0)
  650.             Neck.C1 = CFrame.new()
  651.             Neck.Parent = torso
  652.         end
  653.         local Limb = char:FindFirstChild("Right Arm")
  654.         if Limb then
  655.  
  656.             Limb.CFrame = torso.CFrame * CFrame.new(1.5, 0, 0)
  657.             local Joint = Instance.new("Glue")
  658.             Joint.Name = "RightShoulder"
  659.             Joint.Part0 = torso
  660.             Joint.Part1 = Limb
  661.             Joint.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  662.             Joint.C1 = CFrame.new(-0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  663.             Joint.Parent = torso
  664.  
  665.             local B = Instance.new("Part")
  666.             B.TopSurface = 0
  667.             B.BottomSurface = 0
  668.             B.formFactor = "Symmetric"
  669.             B.Size = Vector3.new(1, 1, 1)
  670.             B.Transparency = 1
  671.             B.CFrame = Limb.CFrame * CFrame.new(0, -0.5, 0)
  672.             B.Parent = char
  673.             B.CanCollide = false
  674.             local W = Instance.new("Weld")
  675.             W.Part0 = Limb
  676.             W.Part1 = B
  677.             W.C0 = CFrame.new(0, -0.5, 0)
  678.             W.Parent = Limb
  679.  
  680.         end
  681.         local Limb = char:FindFirstChild("Left Arm")
  682.         if Limb then
  683.  
  684.             Limb.CFrame = torso.CFrame * CFrame.new(-1.5, 0, 0)
  685.             local Joint = Instance.new("Glue")
  686.             Joint.Name = "LeftShoulder"
  687.             Joint.Part0 = torso
  688.             Joint.Part1 = Limb
  689.             Joint.C0 = CFrame.new(-1.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  690.             Joint.C1 = CFrame.new(0, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  691.             Joint.Parent = torso
  692.  
  693.             local B = Instance.new("Part")
  694.             B.TopSurface = 0
  695.             B.BottomSurface = 0
  696.             B.formFactor = "Symmetric"
  697.             B.Size = Vector3.new(1, 1, 1)
  698.             B.Transparency = 1
  699.             B.CFrame = Limb.CFrame * CFrame.new(0, -0.5, 0)
  700.             B.Parent = char
  701.             B.CanCollide = false
  702.             local W = Instance.new("Weld")
  703.             W.Part0 = Limb
  704.             W.Part1 = B
  705.             W.C0 = CFrame.new(0, -0.5, 0)
  706.             W.Parent = Limb
  707.  
  708.         end
  709.         local Limb = char:FindFirstChild("Right Leg")
  710.         if Limb then
  711.  
  712.             Limb.CFrame = torso.CFrame * CFrame.new(0.5, -2, 0)
  713.             local Joint = Instance.new("Glue")
  714.             Joint.Name = "RightHip"
  715.             Joint.Part0 = torso
  716.             Joint.Part1 = Limb
  717.             Joint.C0 = CFrame.new(0.5, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  718.             Joint.C1 = CFrame.new(0, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  719.             Joint.Parent = torso
  720.  
  721.             local B = Instance.new("Part")
  722.             B.TopSurface = 0
  723.             B.BottomSurface = 0
  724.             B.formFactor = "Symmetric"
  725.             B.Size = Vector3.new(1, 1, 1)
  726.             B.Transparency = 1
  727.             B.CFrame = Limb.CFrame * CFrame.new(0, -0.5, 0)
  728.             B.Parent = char
  729.             B.CanCollide = false
  730.             local W = Instance.new("Weld")
  731.             W.Part0 = Limb
  732.             W.Part1 = B
  733.             W.C0 = CFrame.new(0, -0.5, 0)
  734.             W.Parent = Limb
  735.  
  736.         end
  737.         local Limb = char:FindFirstChild("Left Leg")
  738.         if Limb then
  739.  
  740.             Limb.CFrame = torso.CFrame * CFrame.new(-0.5, -2, 0)
  741.             local Joint = Instance.new("Glue")
  742.             Joint.Name = "LeftHip"
  743.             Joint.Part0 = torso
  744.             Joint.Part1 = Limb
  745.             Joint.C0 = CFrame.new(-0.5, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  746.             Joint.C1 = CFrame.new(-0, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  747.             Joint.Parent = torso
  748.  
  749.             local B = Instance.new("Part")
  750.             B.TopSurface = 0
  751.             B.BottomSurface = 0
  752.             B.formFactor = "Symmetric"
  753.             B.Size = Vector3.new(1, 1, 1)
  754.             B.Transparency = 1
  755.             B.CFrame = Limb.CFrame * CFrame.new(0, -0.5, 0)
  756.             B.Parent = char
  757.             B.CanCollide = false
  758.             local W = Instance.new("Weld")
  759.             W.Part0 = Limb
  760.             W.Part1 = B
  761.             W.C0 = CFrame.new(0, -0.5, 0)
  762.             W.Parent = Limb
  763.         end
  764.         for blood = 0, 3 do
  765.             local blood = Instance.new("Part", workspace)
  766.             blood.BrickColor = BrickColor.Red()
  767.             blood.FormFactor = "Custom"
  768.             blood.Size = Vector3.new(.2,.2,.2)
  769.             blood.Anchored = true
  770.             blood.TopSurface = "Smooth"
  771.             blood.BackSurface = "Smooth"
  772.             local bloodmesh = Instance.new("CylinderMesh", blood)
  773.             bloodmesh.Scale = Vector3.new(3, 0, 3)
  774.             local rayzb = Ray.new(torso.Position, Vector3.new(0, -20, 0) + Vector3.new(math.random(-2, 2), 0, math.random(-2, 2)))
  775.             local hitzb, hitposb = workspace:findPartOnRay(rayzb, char)
  776.             if hitzb then
  777.             blood.CFrame = CFrame.new(hitposb.x,hitposb.y,hitposb.z)
  778.             blood.CFrame = blood.CFrame * CFrame.new(0, .05, 0)
  779.                 coroutine.wrap(function()
  780.                     for cframe = 0, math.random(16, 24) do
  781.                         bloodmesh.Scale = bloodmesh.Scale + Vector3.new(.45, 0, .45)
  782.                         wait()
  783.                     end
  784.                 end)()
  785.             elseif not hitzb then
  786.             blood:Destroy()
  787.             end
  788.         end
  789.         local BP = Instance.new("BodyPosition", torso)
  790.         BP.maxForce = Vector3.new(1,1,1)/0
  791.         BP.position = deathpos
  792.         for i,v in pairs(char:children()) do
  793.             if v:IsA("Part") then v.Parent = WorkModel end
  794.         end
  795.         wait(.3)
  796.         BP:Destroy()
  797.     end
  798. end)
  799.  
  800. local rlegm = Instance.new("Motor", torso)
  801. rlegm.C0 = CFrame.new(0.5, -1, 0)
  802. rlegm.C1 = CFrame.new(0, 1, 0)
  803. rlegm.Part0 = torso
  804. rlegm.Part1 = rl
  805. rlegm.Name = "Right Hip"
  806. local llegm = Instance.new("Motor", torso)
  807. llegm.C0 = CFrame.new(-0.5, -1, 0)
  808. llegm.C1 = CFrame.new(0, 1, 0)
  809. llegm.Part0 = torso
  810. llegm.Part1 = ll
  811. llegm.Name = "Left Hip"
  812. neck.C0 = CFrame.new(0, 1, 0)
  813. neck.C1 = CFrame.new(0, -0.5, 0)
  814. rj.C0 = CFrame.new(0, -1, 0)
  815. rj.C1 = CFrame.new(0, -1, 0)
  816. rsc0 = rm.C0
  817. lsc0 = lm.C0
  818. neckc0 = neck.C0
  819. rootc0 = rj.C0
  820. llc0 = llegm.C0
  821. rlc0 = rlegm.C0
  822. speed = 0.4
  823. angle = 0
  824. anglespeed = 0
  825. mvmnt = 0
  826. game:service'RunService'.RenderStepped:connect(function()
  827.     angle = (angle % 100) + anglespeed/10
  828.     mvmnt = math.pi * math.sin(math.pi*2/100*(angle*10))
  829.         local rscf = rsc0
  830.         local lscf = lsc0
  831.         local rlcf = rlc0
  832.         local llcf = llc0
  833.         local rjcf = rootc0
  834.         local ncf = neckc0
  835.         local rayz = Ray.new(rootpart.Position, Vector3.new(0, -4.1, 0))
  836.         local hitz, enz = workspace:findPartOnRay(rayz, char)
  837.         --math.asin(mouse.UnitRay.Direction.y)
  838.         ncf = neckc0 * CFrame.Angles(camera.CoordinateFrame.lookVector.y, 0, 0)
  839.         rscf = rsc0 * CFrame.new(-.55, 0, .35) * CFrame.Angles(camera.CoordinateFrame.lookVector.y+math.pi/2, 0, 0)
  840.         lscf = lsc0 * CFrame.new(.85, 0, -.65) * CFrame.Angles(camera.CoordinateFrame.lookVector.y+math.pi/2, 0, math.rad(45))
  841.         if firing then
  842.             rscf = rsc0 * CFrame.new(-.55, .15, .65) * CFrame.Angles(camera.CoordinateFrame.lookVector.y+math.pi/2, 0, 0)
  843.             lscf = lsc0 * CFrame.new(.85, .15, -.35) * CFrame.Angles(camera.CoordinateFrame.lookVector.y+math.pi/2, 0, math.rad(45))
  844.         end
  845.         if not hitz then
  846.             ncf = neckc0 * CFrame.Angles(math.pi/18, 0, 0)
  847.                 rscf = rsc0 * CFrame.new(-.45, 0, -.75) * CFrame.Angles(math.pi/5+math.pi/18, 0, math.rad(-70))
  848.                 lscf = lsc0 * CFrame.new(.35, 0, 0) * CFrame.Angles(math.pi/3.5+math.pi/18, 0, 0)
  849.             rjcf = rootc0 * CFrame.Angles(-math.pi/32, 0, 0)
  850.                 rlcf = rlc0 * CFrame.new(0, 0.7, -0.5) * CFrame.Angles(-math.pi/14, 0, 0)
  851.                 llcf = llc0 * CFrame.Angles(-math.pi/20, 0, 0)
  852.         elseif humanoid.Sit then
  853.             ncf = neckc0 * CFrame.Angles(0, 0, 0)
  854.             rjcf = rootc0 * CFrame.new(0, -.2, 0)
  855.             rlcf = rlc0 * CFrame.Angles(math.pi/2, 0, math.rad(7.5))
  856.             llcf = llc0 * CFrame.Angles(math.pi/2, 0, -math.rad(7.5))
  857.             if sprinting then
  858.                 debounceofsprint = false
  859.                 sprinting = false
  860.             end
  861.         elseif Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude <= 2 then
  862.             speed = 0.3
  863.             if ctrl then
  864.                 rjcf = rootc0 * CFrame.new(0, -1.25, 0)
  865.                 llcf = llc0 * CFrame.new(0, 0, -.45) * CFrame.Angles(-math.pi/2.2, 0, 0)
  866.                 rlcf = rlcf * CFrame.new(0, 1.25, -.85)
  867.             else
  868.                 rjcf = rootc0
  869.                 rlcf = rlc0 * CFrame.Angles(-math.rad(.5), 0, math.rad(1.5))
  870.                 llcf = llc0 * CFrame.Angles(math.rad(1.5), 0, -math.rad(1.5))
  871.             end
  872.     elseif Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude <= 20 then
  873.         if not humanoid.Sit then
  874.             anglespeed = 2
  875.             if ctrl then
  876.                 anglespeed = 3
  877.                 ncf = neckc0 * CFrame.Angles(camera.CoordinateFrame.lookVector.y+math.pi/18, 0, 0)
  878.                 rjcf = rootc0 * CFrame.new(0, -.35, 0) * CFrame.Angles(-math.pi/18, 0, 0)
  879.                 rscf = rsc0 * CFrame.new(-.55, 0, .35) * CFrame.Angles(camera.CoordinateFrame.lookVector.y+math.pi/2+math.pi/18, 0, 0)
  880.                 lscf = lsc0 * CFrame.new(.85, 0, -.65) * CFrame.Angles(camera.CoordinateFrame.lookVector.y+math.pi/2+math.pi/18, 0, math.rad(45))
  881.                 llcf = llc0 * CFrame.new(0, .45, -.35) * CFrame.Angles(math.pi/18 - math.sin(angle)*.45, 0, 0)
  882.                 rlcf = rlcf * CFrame.new(0, .45, -.35) * CFrame.Angles(math.pi/18 + math.sin(angle)*.45, 0, 0)
  883.             else
  884.                 rjcf = rootc0
  885.                 rlcf = rlc0 * CFrame.Angles(math.sin(-angle)*.65, 0, math.rad(.5))
  886.                 llcf = llc0 * CFrame.Angles(math.sin(angle)*.65, 0, -math.rad(.5))
  887.             end
  888.             if sprinting then
  889.                 debounceofsprint = false
  890.                 sprinting = false
  891.             end
  892.             end
  893.         elseif Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude >= 20 then
  894.             if not humanoid.Sit then
  895.             anglespeed = 2.7
  896.                 ncf = neckc0 * CFrame.Angles(math.pi/18, 0, 0)
  897.                 rscf = rsc0 * CFrame.new(-.45, 0, -.75) * CFrame.Angles(math.pi/5+math.pi/18, 0, math.rad(-70))
  898.                 lscf = lsc0 * CFrame.new(.35, 0, 0) * CFrame.Angles(math.pi/3.5+math.pi/18, 0, 0)
  899.                 rjcf = rootc0 * CFrame.new(0, 0, 0) * CFrame.Angles(-math.pi/18, math.sin(angle)*.1, math.sin(angle)*.045)
  900.                 rlcf = rlc0 * CFrame.new(0, .3 + -math.cos(-angle)*.3, -.2+math.sin(angle)*0.25) * CFrame.Angles(-math.pi/18+math.sin(-angle)*1.3, 0, math.rad(.5))
  901.                 llcf = llc0 * CFrame.new(0, .3 - -math.cos(angle)*.3, -.05-math.sin(angle)*0.25) * CFrame.Angles(-math.pi/18+math.sin(angle)*1.3, 0, -math.rad(.5))
  902.             sprinting = true
  903.             debounceofsprint = true
  904.             end
  905.         end
  906.     rm.C0 = clerp(rm.C0,rscf,speed)
  907.     lm.C0 = clerp(lm.C0,lscf,speed)
  908.     rj.C0 = clerp(rj.C0,rjcf,speed)
  909.     rlegm.C0 = clerp(rlegm.C0,rlcf,speed)
  910.     llegm.C0 = clerp(llegm.C0,llcf,speed)
  911.     neck.C0 = clerp(neck.C0,ncf,speed)
  912. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement