Advertisement
KrYn0MoRe

old character v1

Apr 19th, 2020 (edited)
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.29 KB | None | 0 0
  1. local plr = owner --game.Players.KrYn0MoRe
  2. local char = plr.Character
  3.  
  4. plr.CharacterAdded:Connect(function(character)
  5.     char = character
  6.     make_sounds(char)
  7.     make_shape(char)
  8.     clear(char)
  9.     make_joints(char)
  10.     make_anims(char)
  11.     give_sword()
  12. end)
  13.  
  14. spawn(function()
  15.     local pos = nil
  16.     local torso = nil
  17.     local tempchar = plr.Character
  18.     if tempchar then
  19.         torso = tempchar:FindFirstChild('Torso')
  20.         pos = torso.CFrame
  21.     end
  22.     plr:LoadCharacter()
  23.     tempchar = plr.Character
  24.     if tempchar and pos then
  25.         torso = tempchar:FindFirstChild('Torso')
  26.         if torso then
  27.             torso.CFrame = pos
  28.         end
  29.     end
  30.     print("Loaded KrYn0MoRe's Old Character v1")
  31. end)
  32.  
  33. function make_shape(char)
  34.     spawn(function()
  35.     if char then
  36.         local CharacterMesh0 = Instance.new("CharacterMesh")
  37.         local CharacterMesh1 = Instance.new("CharacterMesh")
  38.         local CharacterMesh2 = Instance.new("CharacterMesh")
  39.         local CharacterMesh3 = Instance.new("CharacterMesh")
  40.         local CharacterMesh4 = Instance.new("CharacterMesh")
  41.         CharacterMesh0.Name = "CL_LeftArm"
  42.         CharacterMesh0.Parent = char
  43.         CharacterMesh0.BodyPart = Enum.BodyPart.LeftArm
  44.         CharacterMesh0.MeshId = 1112256772
  45.         CharacterMesh1.Name = "CL_LeftLeg"
  46.         CharacterMesh1.Parent = char
  47.         CharacterMesh1.BodyPart = Enum.BodyPart.LeftLeg
  48.         CharacterMesh1.MeshId = 1112275294
  49.         CharacterMesh2.Name = "CL_RightArm"
  50.         CharacterMesh2.Parent = char
  51.         CharacterMesh2.BodyPart = Enum.BodyPart.RightArm
  52.         CharacterMesh2.MeshId = 1112244824
  53.         CharacterMesh3.Name = "CL_RightLeg"
  54.         CharacterMesh3.Parent = char
  55.         CharacterMesh3.BodyPart = Enum.BodyPart.RightLeg
  56.         CharacterMesh3.MeshId = 1112267576
  57.         CharacterMesh4.Name = "CL_Torso"
  58.         CharacterMesh4.Parent = char
  59.         CharacterMesh4.BodyPart = Enum.BodyPart.Torso
  60.         CharacterMesh4.MeshId = 1112228624
  61.     end
  62.     end)
  63. end
  64.  
  65. function clear(char)
  66.     --wait(0.1)
  67.     for i,v in pairs(char:GetChildren()) do
  68.         if v.Name == 'Animate' then
  69.             v:Destroy()
  70.         end
  71.         if v:IsA('Humanoid') then
  72.             for i,vv in pairs(v:GetChildren()) do
  73.                 vv:Destroy()
  74.             end
  75.         end
  76.         if v.Name == 'HumanoidRootPart' then
  77.             for i,vv in pairs(v:GetChildren()) do
  78.                 if vv:IsA('Sound') then
  79.                     vv.Archivable = true
  80.                 end
  81.             end
  82.         end
  83.         if v.Name ~= 'Head' then
  84.             for i,vv in pairs(v:GetChildren()) do
  85.                 if vv:IsA('Attachment') then
  86.                     vv:Destroy()
  87.                 end
  88.             end
  89.         end
  90.         if v.Name == 'Torso' then
  91.             for i,vv in pairs(v:GetChildren()) do
  92.                 if vv:IsA('Motor6D') then
  93.                     vv:Destroy()
  94.                 end
  95.             end
  96.         end
  97.     end
  98. end
  99.  
  100. function make_joints(char)
  101.     local torso = char:FindFirstChild('Torso')
  102.     local lleg,rleg,larm,rarm,head = char:FindFirstChild('Left Leg'),char:FindFirstChild('Right Leg'),char:FindFirstChild('Left Arm'),char:FindFirstChild('Right Arm'),char:FindFirstChild('Head')
  103.     if torso then
  104.         local Motor6D0 = Instance.new("Motor6D")
  105.         local Motor6D1 = Instance.new("Motor6D")
  106.         local Motor6D2 = Instance.new("Motor6D")
  107.         local Motor6D3 = Instance.new("Motor6D")
  108.         local Motor6D4 = Instance.new("Motor6D")
  109.         Motor6D0.Name = "Left Hip"
  110.         Motor6D0.Parent = torso
  111.         Motor6D0.MaxVelocity = 0.1
  112.         Motor6D0.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  113.         Motor6D0.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  114.         Motor6D0.Part0 = torso
  115.         Motor6D0.Part1 = lleg
  116.         Motor6D1.Name = "Left Shoulder"
  117.         Motor6D1.Parent = torso
  118.         Motor6D1.MaxVelocity = 0.15
  119.         Motor6D1.C0 = CFrame.new(2, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  120.         Motor6D1.C1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  121.         Motor6D1.Part0 = larm
  122.         Motor6D1.Part1 = torso
  123.         Motor6D2.Name = "Neck"
  124.         Motor6D2.Parent = torso
  125.         Motor6D2.MaxVelocity = 0.1
  126.         Motor6D2.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  127.         Motor6D2.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  128.         Motor6D2.Part0 = torso
  129.         Motor6D2.Part1 = head
  130.         Motor6D3.Name = "Right Hip"
  131.         Motor6D3.Parent = torso
  132.         Motor6D3.MaxVelocity = 0.1
  133.         Motor6D3.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  134.         Motor6D3.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  135.         Motor6D3.Part0 = torso
  136.         Motor6D3.Part1 = rleg
  137.         Motor6D4.Name = "Right Shoulder"
  138.         Motor6D4.Parent = torso
  139.         Motor6D4.MaxVelocity = 0.15
  140.         Motor6D4.C0 = CFrame.new(-2, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  141.         Motor6D4.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  142.         Motor6D4.Part0 = rarm
  143.         Motor6D4.Part1 = torso
  144.     end
  145. end
  146.  
  147. function make_sounds(char)
  148. spawn(function()
  149. -- util
  150.  
  151. local function waitForChild(parent, childName)
  152.     local child = parent:findFirstChild(childName)
  153.     if child then return child end
  154.     while true do
  155.         child = parent.ChildAdded:wait()
  156.         if child.Name==childName then return child end
  157.     end
  158. end
  159.  
  160. local function newSound(id,name)
  161.     local sound = Instance.new("Sound")
  162.     sound.Name = name or 'Sound'
  163.     sound.SoundId = id
  164.     sound.Volume = 1
  165.     sound.Parent = char['Head']
  166.     return sound
  167. end
  168.  
  169. -- declarations
  170.  
  171. local sDied = newSound("rbxasset://sounds/uuhhh.wav",'Die') -- Die
  172. local sFallingDown = newSound("rbxasset://sounds/splat.wav",'Trip') -- Trip
  173. local sFreeFalling = newSound("rbxasset://sounds/swoosh.wav",'Fall') -- Fall
  174. local sGettingUp = newSound("rbxasset://sounds/hit.wav",'GetUp') -- GetUp
  175. local sJumping = newSound("rbxasset://sounds/button.wav",'Jump') -- Jump
  176. local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3",'Walk') -- Walk
  177. sRunning.Looped = true
  178.  
  179. local Figure = char
  180. local Head = waitForChild(Figure, "Head")
  181. local Humanoid = waitForChild(Figure, "Humanoid")
  182.  
  183. -- functions
  184.  
  185. local function onDied()
  186.     sDied:Play()
  187. end
  188.  
  189. local function onState(state, sound)
  190.     if state then
  191.         sound:Play()
  192.     else
  193.         sound:Pause()
  194.     end
  195. end
  196.  
  197. local function onRunning(speed)
  198.     if speed>0 then
  199.         sRunning:Play()
  200.     else
  201.         sRunning:Pause()
  202.     end
  203. end
  204.  
  205. -- connect up
  206.  
  207. Humanoid.Died:connect(onDied)
  208. Humanoid.Running:connect(onRunning)
  209. Humanoid.Jumping:connect(function(state) onState(state, sJumping) end)
  210. Humanoid.GettingUp:connect(function(state) onState(state, sGettingUp) end)
  211. Humanoid.FreeFalling:connect(function(state) onState(state, sFreeFalling) end)
  212. Humanoid.FallingDown:connect(function(state) onState(state, sFallingDown) end)
  213. --[[
  214. local function waitForChild(parent, childName)
  215.     local child = parent:findFirstChild(childName)
  216.     if child then return child end
  217.     while true do
  218.         child = parent.ChildAdded:wait()
  219.         if child.Name==childName then return child end
  220.     end
  221. end
  222.  
  223. local function newSound(id,p)
  224.     local sound = Instance.new("Sound")
  225.     sound.SoundId = id
  226.     sound.archivable = false
  227.     sound.Parent = p
  228.     return sound
  229. end
  230.  
  231. local Figure = char
  232. local Head = waitForChild(Figure, "Head")
  233. local Humanoid = waitForChild(Figure, "Humanoid")
  234.  
  235. local sFallingDown = newSound("rbxasset://sounds/splat.wav",Head)
  236. sFallingDown.Name = "Trip"
  237. local sGettingUp = newSound("rbxasset://sounds/hit.wav",Head)
  238. sGettingUp.Name = "GetUp"
  239. local sDied = newSound("rbxasset://sounds/uuhhh.mp3",Head)
  240. sDied.Name = "Die"
  241. local sFreeFalling = newSound("rbxassetid://138079657",Head)
  242. sFreeFalling.Name = "Fall"
  243. local sJumping = newSound("rbxasset://sounds/swoosh.wav",Head)
  244. sJumping.Name = "Jump"
  245. local sLanding = newSound("rbxassetid://138079657",Head)
  246. sLanding.Name = "Land"
  247. local sSplash = newSound("rbxassetid://138079657",Head)
  248. sSplash.Name = "Splash"
  249. local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3",Head)
  250. sRunning.Name = "Walk"
  251. sRunning.Looped = true
  252. local sSwimming = newSound("rbxassetid://138079657",Head)
  253. sSwimming.Name = "Swim"
  254. sSwimming.Looped = true
  255. local sClimbing = newSound("rbxassetid://138079657",Head)
  256. sClimbing.Name = "Climb"
  257. sClimbing.Looped = true
  258.  
  259. local prevState = "None"
  260.  
  261. local function stopLoopedSounds()
  262.     sRunning:Stop()
  263.     sClimbing:Stop()
  264.     sSwimming:Stop()
  265. end
  266.  
  267. local function onDied()
  268.     stopLoopedSounds()
  269.     sDied:Play()
  270. end
  271.  
  272. local fallCount = 0
  273. local fallSpeed = 0
  274. local function onStateFall(state, sound)
  275.     fallCount = fallCount + 1
  276.     if state then
  277.         sound.Volume = 0
  278.         sound:Play()
  279.         spawn(function()
  280.             local t = 0
  281.             local thisFall = fallCount
  282.             while t < 1.5 and (fallCount == thisFall) do
  283.                 local vol = math.max(t - 0.3 , 0)
  284.                 sound.Volume = vol
  285.                 wait(0.1)
  286.                 t = t + 0.1
  287.             end
  288.         end)
  289.     else
  290.         sound:Stop()
  291.     end
  292.     fallSpeed = math.max(fallSpeed, math.abs(Head.Velocity.Y))
  293. end
  294.  
  295. local function onStateNoStop(state, sound)
  296.     if state then
  297.         sound:Play()
  298.     end
  299. end
  300.  
  301. local function onRunning(speed)
  302.     sClimbing:Stop()
  303.     sSwimming:Stop()
  304.     if (prevState == "FreeFall" and fallSpeed > 0.1) then
  305.         local vol = math.min(1.0, math.max(0.0, (fallSpeed - 50) / 110))
  306.         sLanding.Volume = vol
  307.         sLanding:Play()
  308.         fallSpeed = 0
  309.     end
  310.     if speed>0.5 then
  311.         sRunning:Play()
  312.         sRunning.Pitch = 1
  313.     else
  314.         sRunning:Stop()
  315.     end
  316.     prevState = "Run"
  317. end
  318.  
  319. local function onSwimming(speed)
  320.     if (prevState ~= "Swim" and speed > 0.1) then
  321.         local volume = math.min(1.0, speed / 350)
  322.         sSplash.Volume = volume
  323.         sSplash:Play()
  324.         prevState = "Swim"
  325.     end
  326.     sClimbing:Stop()
  327.     sRunning:Stop()
  328.     sSwimming.Pitch = 1.6
  329.     sSwimming:Play()
  330. end
  331.  
  332. local function onClimbing(speed)
  333.     sRunning:Stop()
  334.     sSwimming:Stop()   
  335.     if speed>0.01 then
  336.         sClimbing:Play()
  337.         sClimbing.Pitch = speed / 5.5
  338.     else
  339.         sClimbing:Stop()
  340.     end
  341.     prevState = "Climb"
  342. end
  343.  
  344. -- connect up
  345.  
  346. Humanoid.Died:connect(onDied)
  347. Humanoid.Running:connect(onRunning)
  348. Humanoid.Swimming:connect(onSwimming)
  349. Humanoid.Climbing:connect(onClimbing)
  350. Humanoid.Jumping:connect(function(state) onStateNoStop(state, sJumping) prevState = "Jump" end)
  351. Humanoid.GettingUp:connect(function(state) stopLoopedSounds() onStateNoStop(state, sGettingUp) prevState = "GetUp" end)
  352. Humanoid.FreeFalling:connect(function(state) stopLoopedSounds() onStateFall(state, sFreeFalling) prevState = "FreeFall" end)
  353. Humanoid.FallingDown:connect(function(state) stopLoopedSounds() onStateNoStop(state, sFallingDown) prevState = "Falling" end)
  354. Humanoid.StateChanged:connect(function(old, new)
  355.     if not (new.Name == "Dead" or
  356.             new.Name == "Running" or
  357.             new.Name == "RunningNoPhysics" or
  358.             new.Name == "Swimming" or
  359.             new.Name == "Jumping" or
  360.             new.Name == "GettingUp" or
  361.             new.Name == "Freefall" or
  362.             new.Name == "FallingDown") then
  363.         stopLoopedSounds()
  364.     end
  365. end)
  366. ]]
  367. end)
  368. end
  369.  
  370. function make_anims(char)
  371. spawn(function()
  372.     local function waitForChild(parent, childName)
  373.         local child = parent:findFirstChild(childName)
  374.         if child then return child end
  375.         spawn(function()
  376.             while true do
  377.                 child = parent.ChildAdded:wait()
  378.                 if child.Name==childName then return child end
  379.             end
  380.         end)
  381.     end
  382.     local Figure = char
  383.     local Torso = waitForChild(Figure, "Torso")
  384.     local RightShoulder = waitForChild(Torso, "Right Shoulder")
  385.     local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  386.     local RightHip = waitForChild(Torso, "Right Hip")
  387.     local LeftHip = waitForChild(Torso, "Left Hip")
  388.     local Neck = waitForChild(Torso, "Neck")
  389.     local Humanoid = waitForChild(Figure, "Humanoid")
  390.     local pose = "Standing"
  391.     local Joints = Torso:GetChildren()
  392.     for All = 1, #Joints do
  393.         if Joints.className == "Motor" or Joints.className == "Motor6D" then
  394.             Joints[All]:Remove()
  395.         end
  396.     end
  397.     ZStat = 1
  398.     ZStat2 = 0
  399.     local pose = "Standing"
  400.     RightShoulder.Part0 = Torso
  401.     RightShoulder.Part1 = Figure["Right Arm"]
  402.     RightShoulder.MaxVelocity = 0.15
  403.     RightShoulder.Name = "Right Shoulder"
  404.     RightShoulder.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  405.     RightShoulder.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  406.     RightShoulder.Parent = Torso
  407.     LeftShoulder.Part0 = Torso
  408.     LeftShoulder.Part1 = Figure["Left Arm"]
  409.     LeftShoulder.MaxVelocity = 0.15
  410.     LeftShoulder.Name = "Left Shoulder"
  411.     LeftShoulder.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  412.     LeftShoulder.C1 = CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  413.     LeftShoulder.Parent = Torso
  414.     RightHip.Part0 = Torso
  415.     RightHip.Part1 = Figure["Right Leg"]
  416.     RightHip.MaxVelocity = 0.1
  417.     RightHip.Name = "Right Hip"
  418.     RightHip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  419.     RightHip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  420.     RightHip.Parent = Torso
  421.     LeftHip.Part0 = Torso
  422.     LeftHip.Part1 = Figure["Left Leg"]
  423.     LeftHip.MaxVelocity = 0.1
  424.     LeftHip.Name = "Left Hip"
  425.     LeftHip.C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  426.     LeftHip.C1 = CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  427.     LeftHip.Parent = Torso
  428.     Neck.Part0 = Torso
  429.     Neck.Part1 = Figure["Head"]
  430.     Neck.MaxVelocity = 0.1
  431.     Neck.Name = "Neck"
  432.     Neck.C0 = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  433.     Neck.C1 = CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  434.     Neck.Parent = Torso
  435.     local toolAnim = "None"
  436.     local toolAnimTime = 0
  437.     local function onRunning(speed)
  438.         if speed>0 then
  439.             pose = "Running"
  440.         else
  441.             pose = "Standing"
  442.         end
  443.     end
  444.     local function onDied()
  445.         pose = "Dead"
  446.     end
  447.     local function onJumping()
  448.         pose = "Jumping"
  449.     end
  450.     local function onClimbing()
  451.         pose = "Climbing"
  452.     end
  453.     local function onGettingUp()
  454.         pose = "GettingUp"
  455.     end
  456.     local function onFreeFall()
  457.         pose = "FreeFall"
  458.     end
  459.     local function onFallingDown()
  460.         pose = "FallingDown"
  461.     end
  462.     local function onSeated()
  463.         pose = "Seated"
  464.     end
  465.     local function onPlatformStanding()
  466.         pose = "PlatformStanding"
  467.     end
  468.     local function moveJump()
  469.         RightShoulder.MaxVelocity = 0.5
  470.         LeftShoulder.MaxVelocity = 0.5
  471.         RightShoulder.DesiredAngle = (3.14/ZStat)
  472.         LeftShoulder.DesiredAngle = (-3.14/ZStat)
  473.         RightHip.DesiredAngle = (0)
  474.         LeftHip.DesiredAngle = (0)
  475.     end
  476.     local function moveFreeFall()
  477.         RightShoulder.MaxVelocity = 0.5
  478.         LeftShoulder.MaxVelocity = 0.5
  479.         RightShoulder.DesiredAngle = (3.14/ZStat)
  480.         LeftShoulder.DesiredAngle = (-3.14/ZStat)
  481.         RightHip.DesiredAngle = (0)
  482.         LeftHip.DesiredAngle = (0)
  483.     end
  484.     local function moveSit()
  485.         RightShoulder.MaxVelocity = 0.15
  486.         LeftShoulder.MaxVelocity = 0.15
  487.         RightShoulder.DesiredAngle = (3.14 /2)
  488.         LeftShoulder.DesiredAngle = (-3.14 /2)
  489.         RightHip.DesiredAngle = (3.14 /2)
  490.         LeftHip.DesiredAngle = (-3.14 /2)
  491.     end
  492.     local function getTool()   
  493.         for _, kid in ipairs(Figure:GetChildren()) do
  494.             if kid.className == "Tool" then return kid end
  495.         end
  496.         return nil
  497.     end
  498.     local function getToolAnim(tool)
  499.         for _, c in ipairs(tool:GetChildren()) do
  500.             if c.Name == "toolanim" and c.className == "StringValue" then
  501.                 return c
  502.             end
  503.         end
  504.         return nil
  505.     end
  506.     local function animateTool()
  507.         if (toolAnim == "None") then
  508.             RightShoulder.DesiredAngle = (1.57)
  509.             return
  510.         end
  511.         if (toolAnim == "Slash") then
  512.             RightShoulder.MaxVelocity = 0.5
  513.             RightShoulder.DesiredAngle = (0)
  514.             return
  515.         end
  516.         if (toolAnim == "Lunge") then
  517.             RightShoulder.MaxVelocity = 0.5
  518.             LeftShoulder.MaxVelocity = 0.5
  519.             RightHip.MaxVelocity = 0.5
  520.             LeftHip.MaxVelocity = 0.5
  521.             RightShoulder.DesiredAngle = (1.57)
  522.             LeftShoulder.DesiredAngle = (1.0)
  523.             RightHip.DesiredAngle = (1.57)
  524.             LeftHip.DesiredAngle = (1.0)
  525.             return
  526.         end
  527.     end
  528.     local function move(time)
  529.         local amplitude
  530.         local frequency
  531.         if (pose == "Jumping") then
  532.             moveJump()
  533.             return
  534.         end
  535.         if (pose == "FreeFall") then
  536.             moveFreeFall()
  537.             return
  538.         end  
  539.         if (pose == "Seated") then
  540.             moveSit()
  541.             return
  542.         end
  543.         local climbFudge = 0
  544.         if (pose == "Running") then
  545.             RightShoulder.MaxVelocity = 0.15
  546.             LeftShoulder.MaxVelocity = 0.15
  547.             amplitude = 1
  548.             frequency = 9
  549.         elseif (pose == "Climbing") then
  550.             RightShoulder.MaxVelocity = 0.5
  551.             LeftShoulder.MaxVelocity = 0.5
  552.             amplitude = 1
  553.             frequency = 9
  554.             climbFudge = 3.14
  555.         else
  556.             amplitude = 0.1
  557.             frequency = 1
  558.         end
  559.         desiredAngle = amplitude * math.sin(time*frequency)
  560.         RightShoulder.DesiredAngle = (desiredAngle + climbFudge) + ZStat2
  561.         LeftShoulder.DesiredAngle = (desiredAngle - climbFudge) -ZStat2
  562.         RightHip.DesiredAngle = (-desiredAngle)
  563.         LeftHip.DesiredAngle = (-desiredAngle)
  564.         local tool = getTool()
  565.         if tool then
  566.             animStringValueObject = getToolAnim(tool)
  567.             if animStringValueObject then
  568.                 toolAnim = animStringValueObject.Value
  569.                 animStringValueObject.Parent = nil
  570.                 toolAnimTime = time + .3
  571.             end
  572.             if time > toolAnimTime then
  573.                 toolAnimTime = 0
  574.                 toolAnim = "None"
  575.             end
  576.             animateTool()
  577.         else
  578.             toolAnim = "None"
  579.             toolAnimTime = 0
  580.         end
  581.     end
  582.     Humanoid.Died:connect(onDied)
  583.     Humanoid.Running:connect(onRunning)
  584.     Humanoid.Jumping:connect(onJumping)
  585.     Humanoid.Climbing:connect(onClimbing)
  586.     Humanoid.GettingUp:connect(onGettingUp)
  587.     Humanoid.FreeFalling:connect(onFreeFall)
  588.     Humanoid.FallingDown:connect(onFallingDown)
  589.     Humanoid.Seated:connect(onSeated)
  590.     Humanoid.PlatformStanding:connect(onPlatformStanding)
  591.     --Humanoid.ChildAdded:connect(CheckTag)
  592.     OriginalTime = 0.1
  593.     Time = OriginalTime
  594.     spawn(function()
  595.         while Figure.Parent~=nil do
  596.             --[[
  597.             Time = Time + 0.1
  598.             wait(OriginalTime)
  599.             move(Time)
  600.             ]]
  601.             local _, time = wait(0.1)
  602.             move(time)
  603.         end
  604.     end)
  605. end)
  606. end
  607.  
  608. function give_sword()
  609. spawn(function()
  610. --[[
  611. local Tool0 = Instance.new("Tool")
  612. local Part1 = Instance.new("Part")
  613. local SpecialMesh2 = Instance.new("SpecialMesh")
  614. local Sound3 = Instance.new("Sound")
  615. local Sound4 = Instance.new("Sound")
  616. local Sound5 = Instance.new("Sound")
  617. Tool0.Name = "ClassicSword"
  618. Tool0.Parent = plr['Backpack']
  619. Tool0.TextureId = "rbxasset://Textures/Sword128.png"
  620. Tool0.Grip = CFrame.new(0, 0, -1.5, 0, 0, 1, 1, 0, 0, 0, 1, 0)
  621. Tool0.GripForward = Vector3.new(-1, -0, -0)
  622. Tool0.GripPos = Vector3.new(0, 0, -1.5)
  623. Tool0.GripRight = Vector3.new(0, 1, 0)
  624. Tool0.GripUp = Vector3.new(0, 0, 1)
  625. Part1.Name = "Handle"
  626. Part1.Parent = Tool0
  627. Part1.CFrame = CFrame.new(214.957138, 4.28734684, -190.317474, 0.0910440385, -0.881099463, 0.464084357, 0.537011683, 0.435894847, 0.722229123, -0.838648558, 0.183463722, 0.512845576)
  628. Part1.Orientation = Vector3.new(-46.2400017, 42.1399994, 50.9300003)
  629. Part1.Position = Vector3.new(214.957138, 4.28734684, -190.317474)
  630. Part1.Rotation = Vector3.new(-54.6199989, 27.6499996, 84.0999985)
  631. Part1.Color = Color3.new(0.388235, 0.372549, 0.384314)
  632. Part1.Size = Vector3.new(1, 0.800000012, 4)
  633. Part1.BottomSurface = Enum.SurfaceType.Smooth
  634. Part1.BrickColor = BrickColor.new("Dark stone grey")
  635. Part1.Locked = true
  636. Part1.Reflectance = 0.40000000596046
  637. Part1.TopSurface = Enum.SurfaceType.Smooth
  638. Part1.brickColor = BrickColor.new("Dark stone grey")
  639. Part1.FormFactor = Enum.FormFactor.Plate
  640. Part1.formFactor = Enum.FormFactor.Plate
  641. SpecialMesh2.Parent = Part1
  642. SpecialMesh2.MeshId = "rbxasset://fonts/sword.mesh"
  643. SpecialMesh2.TextureId = "rbxasset://textures/SwordTexture.png"
  644. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  645. Sound3.Name = "SwordSlash"
  646. Sound3.Parent = Part1
  647. Sound3.SoundId = "http://www.roblox.com/asset/?id=12222216"
  648. Sound3.Volume = 0.69999998807907
  649. Sound4.Name = "SwordLunge"
  650. Sound4.Parent = Part1
  651. Sound4.SoundId = "http://www.roblox.com/asset/?id=12222208"
  652. Sound4.Volume = 0.60000002384186
  653. Sound5.Name = "Unsheath"
  654. Sound5.Parent = Part1
  655. Sound5.SoundId = "http://www.roblox.com/asset/?id=12222225"
  656. Sound5.Volume = 1
  657.  
  658. local Tool = Tool0
  659. local Handle = Tool:WaitForChild("Handle")
  660.  
  661. local function Create(ty)
  662.     return function(data)
  663.         local obj = Instance.new(ty)
  664.         for k, v in pairs(data) do
  665.             if type(k) == 'number' then
  666.                 v.Parent = obj
  667.             else
  668.                 obj[k] = v
  669.             end
  670.         end
  671.         return obj
  672.     end
  673. end
  674.  
  675. local BaseUrl = "rbxassetid://"
  676.  
  677. local Players = game:GetService("Players")
  678. local Debris = game:GetService("Debris")
  679. local RunService = game:GetService("RunService")
  680.  
  681. local DamageValues = {
  682.     BaseDamage = 5,
  683.     SlashDamage = 10,
  684.     LungeDamage = 30
  685. }
  686.  
  687. --For R15 avatars
  688. local Animations = {
  689.     R15Slash = 522635514,
  690.     R15Lunge = 522638767
  691. }
  692.  
  693. local Damage = DamageValues.BaseDamage
  694.  
  695. local Grips = {
  696.     Up = CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0),
  697.     Out = CFrame.new(0, 0, -1.70000005, 0, 1, 0, 1, -0, 0, 0, 0, -1)
  698. }
  699.  
  700. local Sounds = {
  701.     Slash = Handle:WaitForChild("SwordSlash"),
  702.     Lunge = Handle:WaitForChild("SwordLunge"),
  703.     Unsheath = Handle:WaitForChild("Unsheath")
  704. }
  705.  
  706. local ToolEquipped = false
  707.  
  708. --For Omega Rainbow Katana thumbnail to display a lot of particles.
  709. for i, v in pairs(Handle:GetChildren()) do
  710.     if v:IsA("ParticleEmitter") then
  711.         v.Rate = 20
  712.     end
  713. end
  714.  
  715. Tool.Grip = Grips.Up
  716. Tool.Enabled = true
  717.  
  718. local function CheckIfAlive()
  719.     return (((Player and Player.Parent and Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent) and true) or false)
  720. end
  721.  
  722. local function IsTeamMate(Player1, Player2)
  723.     return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
  724. end
  725.  
  726. local function TagHumanoid(humanoid, player)
  727.     local Creator_Tag = Instance.new("ObjectValue")
  728.     Creator_Tag.Name = "creator"
  729.     Creator_Tag.Value = player
  730.     Debris:AddItem(Creator_Tag, 2)
  731.     Creator_Tag.Parent = humanoid
  732. end
  733.  
  734. local function UntagHumanoid(humanoid)
  735.     for i, v in pairs(humanoid:GetChildren()) do
  736.         if v:IsA("ObjectValue") and v.Name == "creator" then
  737.             v:Destroy()
  738.         end
  739.     end
  740. end
  741.  
  742. local function Blow(Hit)
  743.     if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped then
  744.         return
  745.     end
  746.     local RightArm = Character:FindFirstChild("Right Arm") or Character:FindFirstChild("RightHand")
  747.     if not RightArm then
  748.         return
  749.     end
  750.     local RightGrip = RightArm:FindFirstChild("RightGrip")
  751.     if not RightGrip or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~= Handle) then
  752.         return
  753.     end
  754.     local character = Hit.Parent
  755.     if character == Character then
  756.         return
  757.     end
  758.     local humanoid = character:FindFirstChildOfClass("Humanoid")
  759.     if not humanoid or humanoid.Health == 0 then
  760.         return
  761.     end
  762.     local player = Players:GetPlayerFromCharacter(character)
  763.     if player and (player == Player) then
  764.         return
  765.     end
  766.     UntagHumanoid(humanoid)
  767.     TagHumanoid(humanoid, Player)
  768.     humanoid:TakeDamage(Damage)
  769. end
  770.  
  771.  
  772. local function Attack()
  773.     Damage = DamageValues.SlashDamage
  774.     Sounds.Slash:Play()
  775.  
  776.     if Humanoid then
  777.         if Humanoid.RigType == Enum.HumanoidRigType.R6 then
  778.             local Anim = Instance.new("StringValue")
  779.             Anim.Name = "toolanim"
  780.             Anim.Value = "Slash"
  781.             Anim.Parent = Tool
  782.         elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
  783.             local Anim = Tool:FindFirstChild("R15Slash")
  784.             if Anim then
  785.                 local Track = Humanoid:LoadAnimation(Anim)
  786.                 Track:Play(0)
  787.             end
  788.         end
  789.     end
  790. end
  791.  
  792. local function Lunge()
  793.     Damage = DamageValues.LungeDamage
  794.  
  795.     Sounds.Lunge:Play()
  796.    
  797.     if Humanoid then
  798.         if Humanoid.RigType == Enum.HumanoidRigType.R6 then
  799.             local Anim = Instance.new("StringValue")
  800.             Anim.Name = "toolanim"
  801.             Anim.Value = "Lunge"
  802.             Anim.Parent = Tool
  803.         elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
  804.             local Anim = Tool:FindFirstChild("R15Lunge")
  805.             if Anim then
  806.                 local Track = Humanoid:LoadAnimation(Anim)
  807.                 Track:Play(0)
  808.             end
  809.         end
  810.     end
  811.    
  812.     wait(0.2)
  813.     Tool.Grip = Grips.Out
  814.     wait(0.6)
  815.     Tool.Grip = Grips.Up
  816.  
  817.     Damage = DamageValues.SlashDamage
  818. end
  819.  
  820. Tool.Enabled = true
  821. LastAttack = 0
  822.  
  823. local function Activated()
  824.     if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
  825.         return
  826.     end
  827.     Tool.Enabled = false
  828.     local Tick = RunService.Stepped:wait()
  829.     if (Tick - LastAttack < 0.2) then
  830.         Lunge()
  831.     else
  832.         Attack()
  833.     end
  834.     LastAttack = Tick
  835.     --wait(0.5)
  836.     Damage = DamageValues.BaseDamage
  837.     local SlashAnim = (Tool:FindFirstChild("R15Slash") or Create("Animation"){
  838.         Name = "R15Slash",
  839.         AnimationId = BaseUrl .. Animations.R15Slash,
  840.         Parent = Tool
  841.     })
  842.    
  843.     local LungeAnim = (Tool:FindFirstChild("R15Lunge") or Create("Animation"){
  844.         Name = "R15Lunge",
  845.         AnimationId = BaseUrl .. Animations.R15Lunge,
  846.         Parent = Tool
  847.     })
  848.     Tool.Enabled = true
  849. end
  850.  
  851. local function Equipped()
  852.     Character = Tool.Parent
  853.     Player = Players:GetPlayerFromCharacter(Character)
  854.     Humanoid = Character:FindFirstChildOfClass("Humanoid")
  855.     Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("HumanoidRootPart")
  856.     if not CheckIfAlive() then
  857.         return
  858.     end
  859.     ToolEquipped = true
  860.     Sounds.Unsheath:Play()
  861. end
  862.  
  863. local function Unequipped()
  864.     Tool.Grip = Grips.Up
  865.     ToolEquipped = false
  866. end
  867.  
  868. Tool.Activated:Connect(Activated)
  869. Tool.Equipped:Connect(Equipped)
  870. Tool.Unequipped:Connect(Unequipped)
  871.  
  872. local Connection = Handle.Touched:Connect(Blow)
  873. ]]
  874. local Tool0 = Instance.new("Tool")
  875. local Part2 = Instance.new("Part")
  876. local SpecialMesh3 = Instance.new("SpecialMesh")
  877. --local Sparkles7 = Instance.new("Sparkles")
  878. --local Sparkles8 = Instance.new("Sparkles")
  879. Tool0.Name = "Darkheart"
  880. Tool0.Parent = plr['Backpack']
  881. Tool0.TextureId = "http://www.roblox.com/asset/?id=16868189"
  882. Tool0.Grip = CFrame.new(0, 0, -1.5, 0, 0, 1, 1, 0, 0, 0, 1, 0)
  883. Tool0.GripForward = Vector3.new(-1, -0, -0)
  884. Tool0.GripPos = Vector3.new(0, 0, -1.5)
  885. Tool0.GripRight = Vector3.new(0, 1, 0)
  886. Tool0.GripUp = Vector3.new(0, 0, 1)
  887. Part2.Name = "Handle"
  888. Part2.Parent = Tool0
  889. Part2.CFrame = CFrame.new(-18.6640892, 0.400011003, 9.11577606, -1, -1.7095083e-06, -2.80470631e-05, 1.70952512e-06, -1, -6.01045372e-07, -2.80470631e-05, -6.01093348e-07, 1)
  890. Part2.Orientation = Vector3.new(0, 0, 180)
  891. Part2.Position = Vector3.new(-18.6640892, 0.400011003, 9.11577606)
  892. Part2.Rotation = Vector3.new(0, 0, 180)
  893. Part2.Color = Color3.new(0.388235, 0.372549, 0.384314)
  894. Part2.Velocity = Vector3.new(-0.00113814184, 0.00240389677, -0.00323618972)
  895. Part2.Size = Vector3.new(1, 0.800000012, 4)
  896. Part2.BottomSurface = Enum.SurfaceType.Smooth
  897. Part2.BrickColor = BrickColor.new("Dark stone grey")
  898. Part2.Reflectance = 0.69999998807907
  899. Part2.RotVelocity = Vector3.new(-0.00962590333, 0.00151013187, -0.0043386193)
  900. Part2.TopSurface = Enum.SurfaceType.Smooth
  901. Part2.brickColor = BrickColor.new("Dark stone grey")
  902. SpecialMesh3.Parent = Part2
  903. SpecialMesh3.MeshId = "rbxasset://fonts/sword.mesh"
  904. SpecialMesh3.Scale = Vector3.new(0.800000012, 0.800000012, 1)
  905. SpecialMesh3.VertexColor = Vector3.new(0, 0, 0)
  906. SpecialMesh3.TextureId = "rbxasset://textures/SwordTexture.png"
  907. SpecialMesh3.MeshType = Enum.MeshType.FileMesh
  908. --[[
  909. Sparkles7.Name = "Sparkles1"
  910. Sparkles7.Parent = Part2
  911. Sparkles7.SparkleColor = Color3.fromRGB(66, 66, 66)
  912. Sparkles8.Name = "Sparkles1"
  913. Sparkles8.Parent = Part2
  914. Sparkles8.SparkleColor = Color3.fromRGB(0, 0, 0)
  915. ]]
  916.  
  917. -------- OMG HAX
  918.  
  919. local r = game:service("RunService")
  920.  
  921.  
  922. local damage = 20
  923.  
  924.  
  925. local slash_damage = 18
  926. local lunge_damage = 36
  927.  
  928. local sword = Part2
  929. local Tool = Tool0
  930.  
  931.  
  932. local SlashSound = Instance.new("Sound")
  933. SlashSound.SoundId = "rbxasset://sounds\\swordslash.wav"
  934. SlashSound.Parent = sword
  935. SlashSound.Volume = .7
  936.  
  937. local LungeSound = Instance.new("Sound")
  938. LungeSound.SoundId = "rbxasset://sounds\\swordlunge.wav"
  939. LungeSound.Parent = sword
  940. LungeSound.Volume = .6
  941.  
  942. local UnsheathSound = Instance.new("Sound")
  943. UnsheathSound.SoundId = "rbxasset://sounds\\unsheath.wav"
  944. UnsheathSound.Parent = sword
  945. UnsheathSound.Volume = 1
  946.  
  947. local function tagHumanoid(humanoid, player)
  948.     local creator_tag = Instance.new("ObjectValue")
  949.     creator_tag.Value = player
  950.     creator_tag.Name = "creator"
  951.     creator_tag.Parent = humanoid
  952.     game:GetService("Debris"):AddItem(creator_tag, 1)
  953. end
  954.  
  955. local function DarkKill(character, humanoid, attacker)
  956.  
  957.     if (character:FindFirstChild("ForceField") ~= nil) then return end
  958.  
  959.     local childs = character:GetChildren()
  960.  
  961.     local colors = {}
  962.  
  963.     tagHumanoid(humanoid, attacker)
  964.     humanoid.Health = 0
  965.  
  966.     for i=1,#childs do
  967.         if (childs[i].className == "Part") then
  968.             colors[i] = childs[i].BrickColor
  969.             childs[i].BrickColor = BrickColor.new(26)
  970.             childs[i].CanCollide = true
  971.             childs[i].Anchored = true
  972.         end
  973.     end
  974.  
  975.     wait(.25)
  976.    
  977.     for i=1,#childs do
  978.         if (childs[i].className == "Part") then
  979.             local b = Instance.new("BodyVelocity")
  980.             b.velocity = Vector3.new(math.random() - .5, 0, math.random() - .5).unit * 80
  981.             b.maxForce = Vector3.new(1e5,1e5,1e5)
  982.             b.Parent = childs[i]
  983.         end
  984.     end
  985.  
  986.     for i=1,#childs do
  987.         if (childs[i].className == "Part") then
  988.             childs[i].Anchored = false
  989.         end
  990.     end
  991. end
  992.  
  993. local function blow(hit)
  994.     local humanoid = hit.Parent:findFirstChild("Humanoid")
  995.     local vCharacter = Tool.Parent
  996.     local vPlayer = game:GetService("Players"):GetPlayerFromCharacter(vCharacter)
  997.     local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
  998.     if humanoid~=nil and humanoid ~= hum and hum ~= nil and hum.Health > 0 and humanoid.Health > 0 then
  999.         -- final check, make sure sword is in-hand
  1000.  
  1001.         local right_arm = vCharacter:FindFirstChild("Right Arm")
  1002.         if (right_arm ~= nil) then
  1003.             local joint = right_arm:FindFirstChild("RightGrip")
  1004.             if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then
  1005.                 hum.Health = hum.Health + (damage * .4)
  1006.                 if humanoid.Health > damage then
  1007.                     tagHumanoid(humanoid, vPlayer)
  1008.                     humanoid:TakeDamage(damage)
  1009.                 else
  1010.                     DarkKill(humanoid.Parent, humanoid, vPlayer)
  1011.                 end
  1012.             end
  1013.         end
  1014.  
  1015.  
  1016.     end
  1017. end
  1018.  
  1019. local function attack()
  1020.     damage = slash_damage
  1021.     SlashSound:play()
  1022.     local anim = Instance.new("StringValue")
  1023.     anim.Name = "toolanim"
  1024.     anim.Value = "Slash"
  1025.     anim.Parent = Tool
  1026. end
  1027.  
  1028. local function swordUp()
  1029.     Tool.GripForward = Vector3.new(-1,0,0)
  1030.     Tool.GripRight = Vector3.new(0,1,0)
  1031.     Tool.GripUp = Vector3.new(0,0,1)
  1032. end
  1033.  
  1034. local function swordOut()
  1035.     Tool.GripForward = Vector3.new(0,0,1)
  1036.     Tool.GripRight = Vector3.new(0,-1,0)
  1037.     Tool.GripUp = Vector3.new(-1,0,0)
  1038. end
  1039.  
  1040. local function swordAcross()
  1041.     -- parry
  1042. end
  1043.  
  1044. local function lunge()
  1045.     damage = lunge_damage
  1046.  
  1047.     LungeSound:play()
  1048.  
  1049.     local anim = Instance.new("StringValue")
  1050.     anim.Name = "toolanim"
  1051.     anim.Value = "Lunge"
  1052.     anim.Parent = Tool
  1053.    
  1054.     local torso = (Tool.Parent:FindFirstChild("Torso") or Tool.Parent:FindFirstChild("HumanoidRootPart"))
  1055.     --[[
  1056.     local force = Instance.new("BodyVelocity")
  1057.     force.velocity = Vector3.new(0,10,0) --(Tool.Parent:FindFirstChild("Torso") or Tool.Parent:FindFirstChild("HumanoidRootPart")).CFrame.lookVector * 80
  1058.     force.Parent = torso
  1059.     ]]
  1060.     wait(0.2)
  1061.     swordOut()
  1062.     wait(0.6)
  1063.     swordUp()
  1064.  
  1065.     damage = slash_damage
  1066. end
  1067.  
  1068. Tool.Enabled = true
  1069. local last_attack = 0
  1070. local function onActivated()
  1071.  
  1072.     if not Tool.Enabled then
  1073.         return
  1074.     end
  1075.  
  1076.     Tool.Enabled = false
  1077.  
  1078.     local character = Tool.Parent;
  1079.     local humanoid = character.Humanoid
  1080.     if humanoid == nil then
  1081.         print("Humanoid not found")
  1082.         return
  1083.     end
  1084.  
  1085.     t = r.Stepped:wait()
  1086.  
  1087.     if (t - last_attack < .2) then
  1088.         pcall(function()
  1089.             lunge()
  1090.         end)
  1091.     else
  1092.         pcall(function()
  1093.             attack()
  1094.         end)
  1095.     end
  1096.  
  1097.     last_attack = t
  1098.  
  1099.     --wait(.5)
  1100.  
  1101.     Tool.Enabled = true
  1102. end
  1103.  
  1104. local function onEquipped()
  1105.     UnsheathSound:play()
  1106. end
  1107.  
  1108.  
  1109. Tool.Activated:connect(onActivated)
  1110. Tool.Equipped:connect(onEquipped)
  1111.  
  1112.  
  1113. local connection = sword.Touched:connect(blow)
  1114. end)
  1115. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement