SansjustSans2

YAH10010s zombie script

Aug 2nd, 2020 (edited)
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --stuff by Rufus14
  2. --animations are made with :lerp()
  3. --NOTE: i thought it was a good idea to share this script from a model
  4. --people may abuse idc im making this script FREE
  5. local npc = script.Parent
  6. local torso = npc.Torso
  7. local head = npc.Head
  8. local leftarm = npc["Left Arm"]
  9. local rightarm = npc["Right Arm"]
  10. local leftleg = npc["Left Leg"]
  11. local rightleg = npc["Right Leg"]
  12. local npchumanoid = npc:findFirstChildOfClass("Humanoid")
  13. npc:findFirstChildOfClass("Humanoid").MaxHealth = math.random(100,300)
  14. npc:findFirstChildOfClass("Humanoid").Health = npc:findFirstChildOfClass("Humanoid").MaxHealth
  15. local footstep = Instance.new("Sound", head)
  16. footstep.Name = "footstep"
  17. footstep.SoundId = "rbxassetid://131436155"
  18. footstep.Volume = 3
  19. --Motor6D's
  20. local neck = torso.Neck
  21. neck.C1 = CFrame.new(0,0,0)
  22. local leftshoulder = torso["Left Shoulder"]
  23. leftshoulder.C1 = CFrame.new(0,0,0)
  24. local rightshoulder = torso["Right Shoulder"]
  25. rightshoulder.C1 = CFrame.new(0,0,0)
  26. local lefthip = torso["Left Hip"]
  27. lefthip.C1 = CFrame.new(0,0,0)
  28. local righthip = torso["Right Hip"]
  29. righthip.C1 = CFrame.new(0,0,0)
  30. if npc:findFirstChild("HumanoidRootPart") then
  31.     if npc.HumanoidRootPart:findFirstChild("RootJoint") then
  32.         root = npc.HumanoidRootPart.RootJoint
  33.         root.C1 = CFrame.new(0,0,0)
  34.     elseif npc.HumanoidRootPart:findFirstChild("Root Hip") then
  35.         root = npc.HumanoidRootPart["Root Hip"]
  36.         root.C1 = CFrame.new(0,0,0)
  37.     end
  38. else
  39.     npchumanoid.Health = 0
  40. end
  41. --
  42. local sight = 80
  43. local walking = false
  44. local attacking = false
  45. local cansay = true
  46. local ragdolldeath = true
  47. local caninfect = true
  48. local canrandomwalk = true
  49. local saycooldown = 0
  50. function walkanim(walkspeed)
  51.     if walkspeed > 2 then
  52.         walking = true
  53.     else
  54.         walking = false
  55.     end
  56. end
  57. npchumanoid.Running:connect(walkanim)
  58. function walkrandomly()
  59.     while wait(math.random(3,6)) do
  60.         if not walking and canrandomwalk then
  61.             npchumanoid.WalkSpeed = 10
  62.             local function createwalkpart()
  63.                 local walkpart = Instance.new("Part", npc)
  64.                 walkpart.Size = Vector3.new(1,1,1)
  65.                 walkpart.Anchored = true
  66.                 walkpart.Material = "Neon"
  67.                 walkpart.Transparency = 1
  68.                 walkpart.BrickColor = BrickColor.new("Maroon")
  69.                 walkpart.CFrame = torso.CFrame * CFrame.new(math.random(-60,60),math.random(-30,30),math.random(-60,60))
  70.                 local path = game:GetService("PathfindingService"):FindPathAsync(torso.Position, walkpart.Position)
  71.                 local waypoints = path:GetWaypoints()
  72.                 if path.Status == Enum.PathStatus.Success then
  73.                     for i,v in pairs(waypoints) do
  74.                         if canrandomwalk then
  75.                             npchumanoid:MoveTo(v.Position)
  76.                             local allow = 0
  77.                             while (torso.Position - v.Position).magnitude > 4 and allow < 25 do
  78.                                 allow = allow + 1
  79.                                 wait()
  80.                             end
  81.                             if v.Action == Enum.PathWaypointAction.Jump then
  82.                                 npchumanoid.Jump = true
  83.                             end
  84.                         end
  85.                     end
  86.                     for i,v in pairs(npc:GetChildren()) do
  87.                         if v.Name == "pospart" then
  88.                             v:destroy()
  89.                         end
  90.                     end
  91.                 else
  92.                     createwalkpart()
  93.                     wait()
  94.                 end
  95.             end
  96.             createwalkpart()
  97.         end
  98.     end
  99. end
  100. function chase()
  101.     while true do
  102.         if not walking then
  103.             for i,v in pairs(workspace:GetChildren()) do
  104.                 if not v:findFirstChild("Zombie AI") and v:findFirstChildOfClass("Humanoid") and v:findFirstChild("Head") then
  105.                     if (v:findFirstChild("Head").Position - npc.Head.Position).magnitude < sight then
  106.                         canrandomwalk = false
  107.                         local thehumanoid = v:findFirstChildOfClass("Humanoid")
  108.                         local pathfinding = false
  109.                         local thehead = v:findFirstChild("Head")
  110.                         while (thehead.Position - npc.Head.Position).magnitude < sight and thehumanoid.Health > 0 and not v:findFirstChild("Zombie AI") do
  111.                             npchumanoid.WalkSpeed = 22
  112.                             npchumanoid:MoveTo(thehead.Position, thehead)
  113.                             local path = game:GetService("PathfindingService"):FindPathAsync(torso.Position, thehead.Position) --find the path from scp's torso to victims head
  114.                             local waypoints = path:GetWaypoints() --get the every point of the path
  115.                             if path.Status == Enum.PathStatus.Success then
  116.                                 for q,w in pairs(waypoints) do --for every point existing..
  117.                                     if q ~= 1 then
  118.                                         local allow = 0
  119.                                         npchumanoid:MoveTo(w.Position, thehead) --...walk to it
  120.                                         while (torso.Position - w.Position).magnitude > 3.8 and allow < 20 do
  121.                                             allow = allow + 1
  122.                                             game:GetService("RunService").Heartbeat:wait()
  123.                                         end
  124.                                         if w.Action == Enum.PathWaypointAction.Jump then
  125.                                             npchumanoid.Jump = true
  126.                                         end
  127.                                         if thehumanoid.Health <= 0 then
  128.                                             break
  129.                                         end
  130.                                         if v:findFirstChild("Zombie AI") then
  131.                                             break
  132.                                         end
  133.                                     end
  134.                                 end
  135.                                 for q,w in pairs(npc:GetChildren()) do
  136.                                     if w.Name == "pospart" then
  137.                                         w:destroy()
  138.                                     end
  139.                                 end
  140.                             else
  141.                                 npchumanoid:MoveTo(thehead.Position, thehead)
  142.                             end
  143.                             wait()
  144.                         end
  145.                         canrandomwalk = true
  146.                     else
  147.                         canrandomwalk = true
  148.                     end
  149.                 end
  150.             end
  151.         end
  152.         wait()
  153.     end
  154. end
  155. candmg = true
  156. function damage(part)
  157.     if part.Parent:findFirstChildOfClass("Humanoid") and part.Name ~= "pospart" and not part.Parent:findFirstChild("Zombie AI") and candmg then
  158.         if part.Parent:findFirstChildOfClass("Humanoid").Health <= 4 and part.Parent:findFirstChildOfClass("Humanoid").Health > 0 then
  159.             part.Parent.Head.CFrame = CFrame.new(part.Parent.Head.Position, head.Position)
  160.             part.Parent:findFirstChildOfClass("Humanoid").WalkSpeed = 0
  161.             part.Parent:findFirstChildOfClass("Humanoid").JumpPower = 0
  162.             local deathrandom = math.random(1,5)
  163.             local deathsound = Instance.new("Sound", part.Parent.Head)
  164.             deathsound.Volume = 0.5
  165.             if deathrandom == 1 then
  166.                 deathsound.SoundId = "rbxassetid://566988981"
  167.             end
  168.             if deathrandom == 2 then
  169.                 deathsound.SoundId = "rbxassetid://884349060"
  170.             end
  171.             if deathrandom == 3 then
  172.                 deathsound.SoundId = "rbxassetid://170399891"
  173.             end
  174.             if deathrandom == 4 then
  175.                 deathsound.SoundId = "rbxassetid://402192395"
  176.             end
  177.             if deathrandom == 5 then
  178.                 deathsound.SoundId = "rbxassetid://1835338424"
  179.             end
  180.             deathsound:Play()
  181.             if not caninfect then
  182.                 part.Parent:findFirstChildOfClass("Humanoid").Health = 0
  183.             end
  184.             if part.Parent:findFirstChild("UpperTorso") then
  185.                 part.Parent:findFirstChildOfClass("Humanoid").Health = 0
  186.             end
  187.             if part.Parent:findFirstChild("Torso") and part.Parent:findFirstChild("HumanoidRootPart") and caninfect then
  188.                 local victim = part.Parent
  189.                 local ok = Instance.new("BoolValue", part.Parent)
  190.                 ok.Name = "Zombie AI"
  191.                 if part.Parent:findFirstChild("Right Arm") then
  192.                     rightarmw = Instance.new("Weld", part.Parent.Torso)
  193.                     rightarmw.Part0 = part.Parent.Torso
  194.                     rightarmw.Part1 = part.Parent["Right Arm"]
  195.                     rightarmw.C0 = CFrame.new(1.5,0,0)
  196.                     rightarmw.Name = "RightArmWeld"
  197.                 end
  198.                 if part.Parent:findFirstChild("Right Leg") then
  199.                     rightlegw = Instance.new("Weld", part.Parent.Torso)
  200.                     rightlegw.Part0 = part.Parent.Torso
  201.                     rightlegw.Part1 = part.Parent["Right Leg"]
  202.                     rightlegw.C0 = CFrame.new(0.5,-2,0)
  203.                     rightlegw.Name = "RightLegWeld"
  204.                 end
  205.                 if part.Parent:findFirstChild("Left Arm") then
  206.                     leftarmw = Instance.new("Weld", part.Parent.Torso)
  207.                     leftarmw.Part0 = part.Parent.Torso
  208.                     leftarmw.Part1 = part.Parent["Left Arm"]
  209.                     leftarmw.C0 = CFrame.new(-1.5,0,0)
  210.                     leftarmw.Name = "LeftArmWeld"
  211.                 end
  212.                 if part.Parent:findFirstChild("Left Leg") then
  213.                     leftlegw = Instance.new("Weld", part.Parent.Torso)
  214.                     leftlegw.Part0 = part.Parent.Torso
  215.                     leftlegw.Part1 = part.Parent["Left Leg"]
  216.                     leftlegw.C0 = CFrame.new(-0.5,-2,0)
  217.                     leftlegw.Name = "LeftLegWeld"
  218.                 end
  219.                 local humanoidrootpartw = Instance.new("Weld", part.Parent.HumanoidRootPart)
  220.                 humanoidrootpartw.Part0 = part.Parent.HumanoidRootPart
  221.                 humanoidrootpartw.Part1 = part.Parent.Torso
  222.                 humanoidrootpartw.Name = "HumanoidRootPartWeld"
  223.                 for i,v in pairs(part.Parent:GetChildren()) do
  224.                     if v.ClassName == "Script" and v.Name ~= "Zombie AI" and v.Name ~= "Health" then
  225.                         v:destroy()
  226.                     end
  227.                 end
  228.                 for i = 0,1 , 0.02 do
  229.                     rightarmw.C0 = rightarmw.C0:lerp(CFrame.new(1.64086914, 0.201171875, 0, 0.939692497, -0.342020094, 0, 0.342020124, 0.939692557, 0, 0, 0, 1),i)
  230.                     leftarmw.C0 = leftarmw.C0:lerp(CFrame.new(-1.98254395, 0.588928223, 0, 0.342020214, 0.939692438, -1.77635663e-15, -0.939692497, 0.342020243, -3.55271368e-15, 0, 3.55271368e-15, 1),i)
  231.                     leftlegw.C0 = leftlegw.C0:lerp(CFrame.new(-0.681274414, -2.07165527, 0, 0.984807611, 0.173648268, 0, -0.173648283, 0.98480767, 0, 0, 0, 1),i)
  232.                     rightlegw.C0 = rightlegw.C0:lerp(CFrame.new(1.0670166, -2.11602783, 0, 0.866025329, -0.499999851, 0, 0.499999881, 0.866025388, 0, 0, 0, 1),i)
  233.                     humanoidrootpartw.C0 = humanoidrootpartw.C0:lerp(CFrame.new(0, -2.60009766, 1.20001221, 0.99999994, 0, 0, 0, -4.37113883e-08, -1, 0, 1, -4.37113883e-08),i)
  234.                     game:GetService("RunService").Heartbeat:wait()
  235.                 end
  236.                 wait(1)
  237.                 part.Parent.Archivable = true
  238.                 for i,v in pairs(part.Parent.Torso:GetChildren()) do
  239.                     if v.ClassName == "Weld" then
  240.                         v:destroy()
  241.                     end
  242.                 end
  243.                 for i,v in pairs(part.Parent.HumanoidRootPart:GetChildren()) do
  244.                     if v.ClassName == "Weld" then
  245.                         v:destroy()
  246.                     end
  247.                 end
  248.                 local clone = victim:Clone()
  249.                 part.Parent:findFirstChildOfClass("Humanoid").Health = 0
  250.                 wait()
  251.                 for i,v in pairs(part.Parent:GetChildren()) do
  252.                     if v.ClassName == "Part" or v.ClassName == "Accessory" then
  253.                         v:destroy()
  254.                     end
  255.                 end
  256.                 local scriptclone = script:Clone()
  257.                 clone.Name = clone.Name.." (Zombie)"
  258.                 clone.Parent = workspace
  259.                 for i,v in pairs(clone:GetChildren()) do
  260.                     if v.ClassName == "Script" and v.Name ~= "Zombie AI" and v.Name ~= "Health" then
  261.                         v.Disabled = true
  262.                     end
  263.                 end
  264.                 scriptclone.Parent = clone
  265.                 victim.Parent = nil
  266.                 wait(0.2)
  267.                 local green = math.random(1,3)
  268.                 if green == 1 then
  269.                     for i,v in pairs(clone:GetChildren()) do
  270.                         if v.ClassName == "MeshPart" or v.ClassName == "Part" then
  271.                             v.BrickColor = BrickColor.new("Sea green")
  272.                         end
  273.                     end
  274.                 end
  275.                 if green == 2 then
  276.                     for i,v in pairs(clone:GetChildren()) do
  277.                         if v.ClassName == "MeshPart" or v.ClassName == "Part" then
  278.                             v.BrickColor = BrickColor.new("Bright green")
  279.                         end
  280.                     end
  281.                 end
  282.                 if green == 3 then
  283.                     for i,v in pairs(clone:GetChildren()) do
  284.                         if v.ClassName == "MeshPart" or v.ClassName == "Part" then
  285.                             v.BrickColor = BrickColor.new("Forest green")
  286.                         end
  287.                     end
  288.                 end
  289.             else
  290.                 local victim = part.Parent
  291.                 victim:findFirstChildOfClass("Humanoid").PlatformStand = true
  292.                 for i,v in pairs(part.Parent:GetChildren()) do
  293.                     if v.ClassName == "Script" and v.Name ~= "Zombie AI" and v.Name ~= "Health" then
  294.                         v:destroy()
  295.                     end
  296.                 end
  297.                 wait(1)
  298.                 part.Parent.Archivable = true
  299.                 if victim:findFirstChild("Torso") then
  300.                     for i,v in pairs(part.Parent.Torso:GetChildren()) do
  301.                         if v.ClassName == "Weld" then
  302.                             v:destroy()
  303.                         end
  304.                     end
  305.                 end
  306.                 for i,v in pairs(part.Parent:GetChildren()) do
  307.                     if v.ClassName == "Script" then
  308.                         v:destroy()
  309.                     end
  310.                 end
  311.                 local clone = victim:Clone()
  312.                 part.Parent:findFirstChildOfClass("Humanoid").Health = 0
  313.                 for i,v in pairs(part.Parent:GetChildren()) do
  314.                     if v.ClassName == "Part" or v.ClassName == "Accessory" then
  315.                         v:destroy()
  316.                     end
  317.                 end
  318.                 local scriptclone = script:Clone()
  319.                 clone.Name = clone.Name.." (Zombie)"
  320.                 clone.Parent = workspace
  321.                 scriptclone.Parent = clone
  322.                 victim.Parent = nil
  323.                 local green = math.random(1,3)
  324.                 if green == 1 then
  325.                     for i,v in pairs(clone:GetChildren()) do
  326.                         if v.ClassName == "MeshPart" or v.ClassName == "Part" then
  327.                             v.BrickColor = BrickColor.new("Sea green")
  328.                         end
  329.                     end
  330.                 end
  331.                 if green == 2 then
  332.                     for i,v in pairs(clone:GetChildren()) do
  333.                         if v.ClassName == "MeshPart" or v.ClassName == "Part" then
  334.                             v.BrickColor = BrickColor.new("Bright green")
  335.                         end
  336.                     end
  337.                 end
  338.                 if green == 3 then
  339.                     for i,v in pairs(clone:GetChildren()) do
  340.                         if v.ClassName == "MeshPart" or v.ClassName == "Part" then
  341.                             v.BrickColor = BrickColor.new("Forest green")
  342.                         end
  343.                     end
  344.                 end
  345.             end
  346.         else
  347.             part.Parent:findFirstChildOfClass("Humanoid"):TakeDamage(4)
  348.         end
  349.     end
  350. end
  351. torso.Touched:connect(damage)
  352. spawn(chase)
  353. spawn(walkrandomly)
  354. function death()
  355.     candmg = false
  356.     if npc:findFirstChild("Health") then
  357.         npc.Health:Remove()
  358.     end
  359.     npchumanoid.Archivable = true
  360.     local zombiecorpse = npchumanoid.Parent:Clone()
  361.     npchumanoid.Parent:destroy()
  362.     zombiecorpse.Parent = workspace
  363.     game.Debris:AddItem(zombiecorpse, 20)
  364.     local Humanoid = zombiecorpse:findFirstChildOfClass("Humanoid")
  365.     local Torso = zombiecorpse.Torso
  366.     Humanoid.PlatformStand = true
  367.     Humanoid:SetStateEnabled("Dead", false)
  368.     for i,v in pairs(Humanoid.Parent.Torso:GetChildren()) do
  369.         if v.ClassName == 'Motor6D' or v.ClassName == 'Weld' then
  370.             v:destroy()
  371.         end
  372.     end
  373.     for i,v in pairs(zombiecorpse:GetChildren()) do
  374.         if v.ClassName == "Part" then
  375.             for q,w in pairs(v:GetChildren()) do
  376.                 if w.ClassName == "BodyPosition" or w.ClassName == "BodyVelocity" then
  377.                     w:destroy()
  378.                 end
  379.             end
  380.         end
  381.     end
  382.     if zombiecorpse:findFirstChild("Head") then
  383.         local deathrandom = math.random(1,6)
  384.         local deathsound = Instance.new("Sound", zombiecorpse.Head)
  385.         deathsound.Volume = 3
  386.         if deathrandom == 1 then
  387.             deathsound.SoundId = "rbxassetid://131138845"
  388.         end
  389.         if deathrandom == 2 then
  390.             deathsound.SoundId = "rbxassetid://131138839"
  391.         end
  392.         if deathrandom == 3 then
  393.             deathsound.SoundId = "rbxassetid://131138850"
  394.         end
  395.         if deathrandom == 4 then
  396.             deathsound.SoundId = "rbxassetid://131138860"
  397.         end
  398.         if deathrandom == 5 then
  399.             deathsound.SoundId = "rbxassetid://131138854"
  400.         end
  401.         if deathrandom == 6 then
  402.             deathsound.SoundId = "rbxassetid://131138848"
  403.         end
  404.         deathsound:Play()
  405.     end
  406.     local function makeconnections(limb, attachementone, attachmenttwo, twistlower, twistupper, upperangle)
  407.         local connection = Instance.new('BallSocketConstraint', limb)
  408.         connection.LimitsEnabled = true
  409.         connection.Attachment0 = attachementone
  410.         connection.Attachment1 = attachmenttwo
  411.         connection.TwistLimitsEnabled = true
  412.         connection.TwistLowerAngle = twistlower
  413.         connection.TwistUpperAngle = twistupper
  414.         connection.UpperAngle = 70
  415.     end
  416.     local function makehingeconnections(limb, attachementone, attachmenttwo, twistlower, twistupper, upperangle)
  417.         local connection = Instance.new('HingeConstraint', limb)
  418.         connection.Attachment0 = attachementone
  419.         connection.Attachment1 = attachmenttwo
  420.         connection.LimitsEnabled = true
  421.         connection.LowerAngle = twistlower
  422.         connection.UpperAngle = twistupper
  423.     end
  424.     Humanoid.Parent['Right Arm'].RightShoulderAttachment.Position = Vector3.new(0, 0.5, 0)
  425.     Torso.RightCollarAttachment.Position = Vector3.new(1.5, 0.5, 0)
  426.     Humanoid.Parent['Left Arm'].LeftShoulderAttachment.Position = Vector3.new(0, 0.5, 0)
  427.     Torso.LeftCollarAttachment.Position = Vector3.new(-1.5, 0.5, 0)
  428.     local RightLegAttachment = Instance.new("Attachment", Humanoid.Parent["Right Leg"])
  429.     RightLegAttachment.Position = Vector3.new(0, 1, 0)
  430.     local TorsoRightLegAttachment = Instance.new("Attachment", Torso)
  431.     TorsoRightLegAttachment.Position = Vector3.new(0.5, -1, 0)
  432.     --
  433.     local LeftLegAttachment = Instance.new("Attachment", Humanoid.Parent["Left Leg"])
  434.     LeftLegAttachment.Position = Vector3.new(0, 1, 0)
  435.     local TorsoLeftLegAttachment = Instance.new("Attachment", Torso)
  436.     TorsoLeftLegAttachment.Position = Vector3.new(-0.5, -1, 0)
  437.     --
  438.     if Humanoid.Parent:findFirstChild("Head") then
  439.         local HeadAttachment = Instance.new("Attachment", Humanoid.Parent.Head)
  440.         HeadAttachment.Position = Vector3.new(0, -0.5, 0)
  441.         makehingeconnections(Humanoid.Parent.Head, HeadAttachment, Torso.NeckAttachment, -20, 20, 70)
  442.     end
  443.     makeconnections(Humanoid.Parent['Right Arm'], Humanoid.Parent['Right Arm'].RightShoulderAttachment, Torso.RightCollarAttachment, -80, 80)
  444.     makeconnections(Humanoid.Parent['Left Arm'], Humanoid.Parent['Left Arm'].LeftShoulderAttachment, Torso.LeftCollarAttachment, -80, 80)
  445.     makeconnections(Humanoid.Parent['Right Leg'], RightLegAttachment, TorsoRightLegAttachment, -80, 80, 70)
  446.     makeconnections(Humanoid.Parent['Left Leg'], LeftLegAttachment, TorsoLeftLegAttachment, -80, 80, 70)
  447.     if Humanoid.Parent:findFirstChild("Right Arm") then
  448.         local limbcollider = Instance.new("Part", Humanoid.Parent["Right Arm"])
  449.         limbcollider.Size = Vector3.new(1,1.3,1)
  450.         limbcollider.Shape = "Cylinder"
  451.         limbcollider.Transparency = 1
  452.         local limbcolliderweld = Instance.new("Weld", limbcollider)
  453.         limbcolliderweld.Part0 = Humanoid.Parent["Right Arm"]
  454.         limbcolliderweld.Part1 = limbcollider
  455.         limbcolliderweld.C0 = CFrame.fromEulerAnglesXYZ(0,0,math.pi/2) * CFrame.new(-0.4,0,0)
  456.         for i,v in pairs(zombiecorpse["Right Arm"]:GetChildren()) do
  457.             if v.ClassName == 'Motor6D' or v.ClassName == 'Weld' then
  458.                 v:destroy()
  459.             end
  460.         end
  461.     end
  462.     --
  463.     if Humanoid.Parent:findFirstChild("Left Arm") then
  464.         local limbcollider = Instance.new("Part", Humanoid.Parent["Left Arm"])
  465.         limbcollider.Size = Vector3.new(1,1.3,1)
  466.         limbcollider.Shape = "Cylinder"
  467.         limbcollider.Transparency = 1
  468.         local limbcolliderweld = Instance.new("Weld", limbcollider)
  469.         limbcolliderweld.Part0 = Humanoid.Parent["Left Arm"]
  470.         limbcolliderweld.Part1 = limbcollider
  471.         limbcolliderweld.C0 = CFrame.fromEulerAnglesXYZ(0,0,math.pi/2) * CFrame.new(-0.4,0,0)
  472.     end
  473.     --
  474.     if Humanoid.Parent:findFirstChild("Left Leg") then
  475.         local limbcollider = Instance.new("Part", Humanoid.Parent["Left Leg"])
  476.         limbcollider.Size = Vector3.new(1,1.3,1)
  477.         limbcollider.Shape = "Cylinder"
  478.         limbcollider.Transparency = 1
  479.         local limbcolliderweld = Instance.new("Weld", limbcollider)
  480.         limbcolliderweld.Part0 = Humanoid.Parent["Left Leg"]
  481.         limbcolliderweld.Part1 = limbcollider
  482.         limbcolliderweld.C0 = CFrame.fromEulerAnglesXYZ(0,0,math.pi/2) * CFrame.new(-0.4,0,0)
  483.     end
  484.     --
  485.     if Humanoid.Parent:findFirstChild("Right Leg") then
  486.         local limbcollider = Instance.new("Part", Humanoid.Parent["Right Leg"])
  487.         limbcollider.Size = Vector3.new(1,1.3,1)
  488.         limbcollider.Shape = "Cylinder"
  489.         limbcollider.Transparency = 1
  490.         local limbcolliderweld = Instance.new("Weld", limbcollider)
  491.         limbcolliderweld.Part0 = Humanoid.Parent["Right Leg"]
  492.         limbcolliderweld.Part1 = limbcollider
  493.         limbcolliderweld.C0 = CFrame.fromEulerAnglesXYZ(0,0,math.pi/2) * CFrame.new(-0.4,0,0)
  494.     end
  495.     local ragdoll = zombiecorpse
  496.     if ragdoll:findFirstChild("HumanoidRootPart") then
  497.         ragdoll.HumanoidRootPart.CanCollide = false
  498.         ragdoll.HumanoidRootPart:destroy()
  499.     end
  500.     wait(0.5)
  501.     for i,v in pairs(ragdoll:GetChildren()) do
  502.         if v.ClassName == 'Script' then
  503.             v.Disabled = true
  504.         end
  505.     end
  506. end
  507. npchumanoid.Died:connect(death)
  508. while wait() do --check animations and other things
  509.     if not walking then
  510.         for i = 0.2,0.8 , 0.09 do
  511.             if not walking then
  512.                 rightshoulder.C0 = rightshoulder.C0:lerp(CFrame.new(1.5, 0.00756835938, -0.0867919922, 1, 0, 0, 0, 0.98480767, -0.173648283, 0, 0.173648283, 0.98480773),i)
  513.                 leftshoulder.C0 = leftshoulder.C0:lerp(CFrame.new(-1.5, 0.00756835938, -0.0867919922, 1, -3.28626015e-14, -1.74845866e-07, -3.03616616e-08, 0.98480767, -0.173648268, 1.72189587e-07, 0.173648268, 0.98480773),i)
  514.                 lefthip.C0 = lefthip.C0:lerp(CFrame.new(-0.5, -1.98486328, -0.173583984, 1, 8.8817842e-16, 0, -8.8817842e-16, 0.98480767, -0.173648268, 0, 0.173648268, 0.98480773),i)
  515.                 righthip.C0 = righthip.C0:lerp(CFrame.new(0.5, -1.98486328, -0.173583984, 1, 0, 0, 0, 0.98480767, -0.173648268, 0, 0.173648268, 0.98480773),i)
  516.                 root.C0 = root.C0:lerp(CFrame.new(0, 0, 0, 1, 0, 0, 0, 0.98480773, 0.173648283, 0, -0.173648283, 0.98480773),i)
  517.                 neck.C0 = neck.C0:lerp(CFrame.new(0, 1.4921875, -0.0867919922, 1, 0, 0, 0, 0.98480767, 0.173648283, 0, -0.173648283, 0.98480767),i)
  518.                 wait()
  519.             end
  520.         end
  521.     end
  522.     if walking then --this is the walking animation
  523.         for i = 0.1,0.9 , 0.09 do
  524.             if walking then
  525.                 rightshoulder.C0 = rightshoulder.C0:lerp(CFrame.new(1.5, 0.586669922, -0.492431641, 1, -3.55271368e-15, 3.55271368e-15, -5.29395592e-23, -0.173648164, -0.984807611, 4.44089252e-15, 0.98480767, -0.173648179),i)
  526.                 leftshoulder.C0 = leftshoulder.C0:lerp(CFrame.new(-1.5, 0.586669922, -0.492431641, 1, 3.55271368e-15, -3.55271368e-15, 5.29395592e-23, -0.173648164, -0.984807611, -4.44089252e-15, 0.98480767, -0.173648179),i)
  527.                 lefthip.C0 = lefthip.C0:lerp(CFrame.new(-0.5, -1.64257813, -0.766113281, 1, 0, 0, 0, 0.642787635, -0.766044378, 0, 0.766044378, 0.642787695),i)
  528.                 righthip.C0 = righthip.C0:lerp(CFrame.new(0.5, -1.8659668, 0.5, 1, 0, 0, 0, 0.866025448, 0.499999881, 0, -0.499999881, 0.866025448),i)
  529.                 root.C0 = root.C0:lerp(CFrame.new(0, 0, 0, 1, 0, 0, 0, 0.98480773, 0.173648298, 0, -0.173648298, 0.98480773),i)
  530.                 neck.C0 = neck.C0:lerp(CFrame.new(0.0311279297, 1.49121094, 0.0867919922, 0.99800092, 0.0622391105, -0.010974437, -0.0631992519, 0.982839048, -0.173301145, -2.79396772e-09, 0.173648268, 0.98480767),i)
  531.                 wait()
  532.             end
  533.         end
  534.         head.footstep:Play()
  535.         for i = 0.1,0.9 , 0.09 do
  536.             if walking then
  537.                 rightshoulder.C0 = rightshoulder.C0:lerp(CFrame.new(1.5, 0.562744141, -0.49609375, 1, 3.55271368e-15, -3.55271368e-15, -3.55271368e-15, -0.125386789, -0.992107928, -2.22044605e-15, 0.992107987, -0.125386804),i)
  538.                 leftshoulder.C0 = leftshoulder.C0:lerp(CFrame.new(-1.5, 0.586669922, -0.492431641, 1, 3.55271368e-15, -3.55271368e-15, 5.29395592e-23, -0.173648164, -0.984807611, -4.44089252e-15, 0.98480767, -0.173648179),i)
  539.                 lefthip.C0 = lefthip.C0:lerp(CFrame.new(-0.5, -1.8659668, 0.5, 1, 0, 0, 0, 0.866025448, 0.499999881, 0, -0.499999881, 0.866025448),i)
  540.                 righthip.C0 = righthip.C0:lerp(CFrame.new(0.5, -1.64257813, -0.766113281, 1, 0, 0, 0, 0.642787516, -0.766044497, 0, 0.766044557, 0.642787576),i)
  541.                 root.C0 = root.C0:lerp(CFrame.new(0, 0, 0, 0.996194661, -1.44354999e-08, 0.0871558934, -0.00759615237, 0.996194661, 0.0868244395, -0.0868242383, -0.0871560946, 0.992403805),i)
  542.                 neck.C0 = neck.C0:lerp(CFrame.new(0, 1.49809742, 0.0435781479, 0.996194601, -1.27129169e-08, -0.0871559009, -0.0075961519, 0.996194661, -0.0868244097, 0.0868242458, 0.0871560723, 0.992403746),i)
  543.                 wait()
  544.             end
  545.         end
  546.         head.footstep:Play()
  547.     end
  548. end
Add Comment
Please, Sign In to add comment