Advertisement
KrYn0MoRe

oa

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