bonniekawaiidesu

sdgf

Mar 1st, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 27.39 KB | None | 0 0
  1. function sandbox(var,func)
  2.     local env = getfenv(func)
  3.     local newenv = setmetatable({},{
  4.         __index = function(self,k)
  5.             if k=="script" then
  6.                 return var
  7.             else
  8.                 return env[k]
  9.             end
  10.         end,
  11.     })
  12.     setfenv(func,newenv)
  13.     return func
  14. end
  15. cors = {}
  16. mas = Instance.new("Model",game:GetService("Lighting"))
  17. Tool0 = Instance.new("Tool")
  18. Part1 = Instance.new("Part")
  19. Fire2 = Instance.new("Fire")
  20. SpecialMesh3 = Instance.new("SpecialMesh")
  21. Weld4 = Instance.new("Weld")
  22. Sound5 = Instance.new("Sound")
  23. Sound6 = Instance.new("Sound")
  24. Sound7 = Instance.new("Sound")
  25. Sparkles8 = Instance.new("Sparkles")
  26. LocalScript9 = Instance.new("LocalScript")
  27. Script10 = Instance.new("Script")
  28. LocalScript11 = Instance.new("LocalScript")
  29. Script12 = Instance.new("Script")
  30. Tool0.Name = "Card"
  31. Tool0.Parent = mas
  32. Tool0.Grip = CFrame.new(0, 0.731632411, 0.429803371, 1, 0, 0, 0, -0.0654020309, 0.997859001, 0, -0.997859001, -0.0654020309)
  33. Tool0.GripForward = Vector3.new(-0, -0.997859001, 0.0654020309)
  34. Tool0.GripPos = Vector3.new(0, 0.731632411, 0.429803371)
  35. Tool0.GripUp = Vector3.new(0, -0.0654020309, -0.997859001)
  36. Part1.Name = "Handle"
  37. Part1.Parent = Tool0
  38. Part1.CFrame = CFrame.new(-67.8400116, 1.6550045, 120.055, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  39. Part1.Position = Vector3.new(-67.8400116, 1.6550045, 120.055)
  40. Part1.Color = Color3.new(1, 0, 0.74902)
  41. Part1.Size = Vector3.new(1.01999986, 1.31000006, 3.05000019)
  42. Part1.BottomSurface = Enum.SurfaceType.Smooth
  43. Part1.BrickColor = BrickColor.new("Hot pink")
  44. Part1.Material = Enum.Material.Neon
  45. Part1.TopSurface = Enum.SurfaceType.Smooth
  46. Part1.brickColor = BrickColor.new("Hot pink")
  47. Fire2.Parent = Part1
  48. Fire2.Color = Color3.new(0.345098, 0.0431373, 0.278431)
  49. Fire2.Heat = 0
  50. Fire2.SecondaryColor = Color3.new(0, 0, 0)
  51. SpecialMesh3.Parent = Part1
  52. SpecialMesh3.MeshId = "http://www.roblox.com/asset/?id=30694864"
  53. SpecialMesh3.Scale = Vector3.new(1, 1, 1.29999995)
  54. SpecialMesh3.MeshType = Enum.MeshType.FileMesh
  55. Weld4.Name = "HandleTipWeld"
  56. Weld4.Parent = Part1
  57. Weld4.C0 = CFrame.new(0, 2.79999995, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  58. Sound5.Name = "SwordLunge"
  59. Sound5.Parent = Part1
  60. Sound5.SoundId = "http://www.roblox.com/asset/?id=12222208"
  61. Sound5.Volume = 0.60000002384186
  62. Sound6.Name = "SwordSlash"
  63. Sound6.Parent = Part1
  64. Sound6.SoundId = "http://www.roblox.com/asset/?id=12222216"
  65. Sound6.Volume = 0.69999998807907
  66. Sound7.Name = "Unsheath"
  67. Sound7.Parent = Part1
  68. Sound7.SoundId = "http://www.roblox.com/asset/?id=12222225"
  69. Sound7.Volume = 1
  70. Sparkles8.Parent = Part1
  71. LocalScript9.Name = "Spear_Main"
  72. LocalScript9.Parent = Tool0
  73. table.insert(cors,sandbox(LocalScript9,function()
  74. --local mDebugId = game.Workspace.DebugId.Value
  75. --game.Workspace.DebugId.Value = game.Workspace.DebugId.Value+1
  76. --print("Running swordscript <"..mDebugId..">")
  77.  
  78. -------------------------------------
  79. -- Makes an RBX::Lua Instance using
  80. -- a table of key-value pairs to
  81. -- initialize it. Values with numeric
  82. -- keys will be parented to the object
  83. -- and other values will be set
  84. -- as members of the object.
  85. function Create(ty)
  86.     return function(data)
  87.         local obj = Instance.new(ty)
  88.         for k, v in pairs(data) do
  89.             if type(k) == 'number' then
  90.                 v.Parent = obj
  91.             else
  92.                 obj[k] = v
  93.             end
  94.         end
  95.         return obj
  96.     end
  97. end
  98.  
  99. ---------------------------------------
  100. -- Same as Make, but modifies an existing
  101.  
  102.  
  103. -- object rather than creating ones.
  104. function Modify(obj, data)
  105.     for k, v in pairs(data) do
  106.         if type(data) == 'number' then
  107.             data.Parent = obj
  108.         else
  109.             data[k] = v
  110.         end
  111.     end
  112.     return obj
  113. end
  114.  
  115. -----------------------------------------
  116. -- Creates a class which can be instantiated
  117. -- using `CreateCLASSNAME( ... )`.
  118. ---usage:
  119. --class'MyClass'(function(this, arg1)
  120. --  this.ClassMember = value
  121. --  function this.ClassMethod(...) ... end
  122. --end, function(def)
  123. --  def.StaticMember = value
  124. --   function def.StaticMethod(...) ... end
  125. --end)
  126. --local obj = CreateMyClass(arg1)
  127. ------------------------------------------
  128. local function class(name)
  129.     local def = {}
  130.     getfenv(0)[name] = def
  131.     return function(ctor, static)
  132.         local nctor = function(...)
  133.             local this = {}
  134.             if ctor then
  135.                 ctor(this, ...)
  136.             end
  137.             return this
  138.         end
  139.         getfenv(0)['Create'..name] = nctor
  140.         if static then static(def) end
  141.     end
  142. end
  143.  
  144.  
  145. ---------------------------------------------
  146. -- Signal class for custom-made events
  147. --API:
  148. -- Signal:connect(callback)
  149. -- Signal:fire(...)
  150. -- Signal:wait()
  151. ---------------------------------------------
  152. class'Signal'(function(this)
  153.     local mListeners = {}
  154.     local mWaitObject = Create'BoolValue'{}
  155.  
  156.     function this:connect(func)
  157.         local connection = {}
  158.         function connection:disconnect()
  159.             mListeners[func] = nil
  160.         end
  161.         mListeners[func] = connection
  162.         return connection
  163.     end
  164.  
  165.     function this:fire(...)
  166.         --print("Fire evt<"..tostring(this).."> from script<"..mDebugId..">")
  167.         for func, conn in pairs(mListeners) do
  168.             --print("-> "..tostring(func).."( ... )")
  169.             func(...)
  170.         end
  171.         mWaitObject.Value = not mWaitObject.Value
  172.     end
  173.  
  174.     function this:wait()
  175.         mWaitObject.Changed:wait()
  176.     end
  177. end)
  178.  
  179.  
  180. --------------------------------------------------
  181. -- Bin class for cleaning up assets
  182. --API:
  183. -- Bin:add(func: Function, ident: String)
  184. -- Bin:clean(ident: String)
  185. -- Bin:cleanAll()
  186. --------------------------------------------------
  187. class'Bin'(function(this)
  188.     local mGarbage = {}
  189.  
  190.     function this:add(func, ident)
  191.         ident = ident or '__unnamed'
  192.         if not mGarbage[ident] then
  193.             mGarbage[ident] = {}
  194.         end
  195.         mGarbage[ident][#mGarbage[ident]+1] = func
  196.     end
  197.  
  198.     function this:clean(ident)
  199.         local listToCall = mGarbage[ident]
  200.         if listToCall then
  201.             for _, func in pairs(listToCall) do
  202.                 func()
  203.             end
  204.             mGarbage[ident] = nil
  205.         end
  206.     end
  207.  
  208.     function this:cleanAll()
  209.         for ident, list in pairs(mGarbage) do
  210.             for _, func in pairs(list) do
  211.                 func()
  212.             end
  213.             mGarbage[ident] = nil
  214.         end
  215.     end
  216. end)
  217.  
  218.  
  219. -----------------------------------------------------
  220. -- AnimationProvider class for easy loading of
  221. -- animation assets into animationtracks once
  222. -- a humanoid is available.
  223. --API:
  224. -- AnimationProvider:registerAnimation(ident, assetid)
  225. -- AnimationProvider:setHumanoid(humanoid)
  226. -- AnimationProvider:setTool(tool)
  227. -- AnimationProvider:getAnimation(ident)
  228. -----------------------------------------------------
  229. class'AnimationProvider'(function(this)
  230.     local mAnimations = {--[[ident => {AnimationId, CurrentTrack, CurrentAnim} ]]}
  231.     local mCurrentHumanoid = nil
  232.  
  233.     function this:registerAnimation(ident, assetid)
  234.         --check for an existing copy of the anim
  235.         local existingAnim = Tool.Tool:FindFirstChild('ANIM_'..ident)
  236.            
  237.         --make the data for this anim
  238.         local animdat = {
  239.             AnimationId = assetid,
  240.             CurrentAnim = existingAnim or Create'Animation'{
  241.                 Name = "ANIM_"..ident,
  242.                 AnimationId = assetid, 
  243.             },
  244.         }
  245.         mAnimations[ident] = animdat
  246.  
  247.         --if there's a current tool, put it in there
  248.         if Tool.Tool then
  249.             Tool.HUGE_EQUIP_HACK = true
  250.             animdat.CurrentAnim.Parent = Tool.Tool
  251.             Tool.HUGE_EQUIP_HACK = false
  252.         end
  253.        
  254.         --if there's a humanoid load the animation track
  255.         if mCurrentHumanoid then
  256.             animdat.CurrentTrack = mCurrentHumanoid:LoadAnimation(animdat.CurrentAnim)
  257.         end
  258.     end
  259.  
  260.     function this:setHumanoid(humanoid)
  261.         mCurrentHumanoid = humanoid
  262.         for _, anim in pairs(mAnimations) do
  263.             anim.CurrentTrack = humanoid:LoadAnimation(anim.CurrentAnim)
  264.         end
  265.     end
  266.  
  267.     function this:getAnimation(ident)
  268.         local dat = mAnimations[ident]
  269.         if not dat then error("Gear Fatal Error: Animation `"..ident.."` not found") end
  270.         if not dat.CurrentTrack then
  271.             error("Gear Fatal Error: No Humanoid for animation `"..ident.."` to run in")
  272.         end
  273.         return dat.CurrentTrack
  274.     end
  275. end)
  276.  
  277.  
  278. ----------------------------------------------
  279. -- SoundProvider class
  280. -- functions similarily to the animationprovider
  281. ----------------------------------------------
  282. class'SoundProvider'(function(this)
  283.     local mSounds = {}
  284.  
  285.     function this:registerSound(ident, assetid, inpart)
  286.         inpart = inpart or Tool.Tool:FindFirstChild('Handle')
  287.         if not inpart then
  288.             repeat
  289.                 inpart = Tool.Tool.ChildAdded:wait()
  290.             until inpart.Name == 'Handle'
  291.         end
  292.         local existingSound = inpart:FindFirstChild('SOUND_'..ident)
  293.         local sounddat = {
  294.             SoundId = assetid,
  295.             CurrentSound = existingSound or Create'Sound'{
  296.                 Name = 'SOUND_'..ident,
  297.                 SoundId = assetid,
  298.                 Parent = inpart,
  299.             },
  300.         }
  301.         mSounds[ident] = sounddat
  302.     end
  303.  
  304.     function this:getSound(ident)
  305.         local dat = mSounds[ident]
  306.         if dat then
  307.             return dat.CurrentSound
  308.         end
  309.     end
  310. end)
  311.  
  312.  
  313. ----------------------------------------------
  314. -- DebounceProvider class -- Prevent events
  315. -- from happening in too rapid succession
  316. ----------------------------------------------
  317. class'DebounceProvider'(function(this)
  318.     local mFlagNameToLastTime = {}
  319.  
  320.     function this:test(ident, delta)
  321.         local t = tick()
  322.         local lastTime = mFlagNameToLastTime[ident] or 0
  323.         if delta then
  324.             return (t-lastTime) > delta
  325.         else
  326.             return mFlagNameToLastTime[ident]
  327.         end
  328.     end
  329.     function this:set(ident, state)
  330.         if state then
  331.             mFlagNameToLastTime[ident] = state
  332.         elseif state == false then
  333.             mFlagNameToLastTime[ident] = false
  334.         else
  335.             mFlagNameToLastTime[ident] = tick()
  336.         end
  337.     end
  338. end)
  339.  
  340.  
  341. function TagHumanoid(humanoid)
  342.     if Tool.Player then
  343.         local tag = Create'ObjectValue'{
  344.             Name = "creator",
  345.             Value = Tool.Player,
  346.             Parent = humanoid,
  347.         }
  348.         game.Debris:AddItem(tag, 1)
  349.     end
  350. end
  351.  
  352.  
  353. ------- wait for any event in a set of events  to fire ------
  354. function WaitForAny(tb)
  355.     local evt = tb
  356.     local conn = {}
  357.     local eventargs = nil
  358.     local waitProxy = Create'BoolValue'{}
  359.     for _, e in pairs(evt) do
  360.         local c = e:connect(function(...)
  361.             for _, c in pairs(conn) do
  362.                 c:disconnect()
  363.             end
  364.             eventargs = {...}
  365.             waitProxy.Value = not waitProxy.Value
  366.         end)
  367.         conn[#conn+1] = c
  368.     end
  369.     --
  370.     waitProxy.Changed:wait()
  371.     --
  372.     return unpack(eventargs)
  373. end
  374.  
  375.  
  376. ----------------------------------------------
  377. -- Tool singleton class
  378. --API:
  379. -- ...
  380. class'Tool'(nil, function(this)
  381.     --need this here for the animationprovider to use
  382.     this.HUGE_EQUIP_HACK = false
  383.  
  384.     this.Bin = CreateBin()
  385.     this.AnimationProvider = CreateAnimationProvider()
  386.     this.DebounceProvider = CreateDebounceProvider()
  387.     this.SoundProvider = CreateSoundProvider()
  388.  
  389.     --general values
  390.     this.Tool = script.Parent
  391.     this.Player = nil
  392.     this.Humanoid = nil
  393.     this.Character = nil
  394.  
  395.     --============ several flags for the gear
  396.     --nothing
  397.  
  398.     --some events
  399.     this.Equipped = CreateSignal()
  400.     this.Unequipped = CreateSignal()
  401.     this.OwnerChange = CreateSignal()
  402.  
  403.     --mouse utility events
  404.     this.MouseClick = CreateSignal()
  405.     this.MouseRelease = CreateSignal()
  406.     this.MouseDoubleClick = CreateSignal()
  407.     this.DoubleClickThreshold = 0.2
  408.     this.MouseDown = false
  409.     this.KeyDown = CreateSignal()
  410.  
  411.     local mLastClickTime = 0
  412.  
  413.     script.Parent.Equipped:connect(function(mouse)
  414.         --print("Internal Equipped: Time b: "..time())
  415.         --set up general values in the tool
  416.         this.Mouse = mouse
  417.         local curOwner = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
  418.         if curOwner ~= this.Player then
  419.             this.Player = curOwner
  420.             this.OwnerChange:fire(this.Player)
  421.         end
  422.         this.Character = this.Player.Character
  423.         this.Humanoid = this.Character.Humanoid
  424.         this.AnimationProvider:setHumanoid(this.Humanoid)
  425.  
  426.         --set up the mouse events
  427.         mouse.Button1Down:connect(function()
  428.             this.MouseDown = true
  429.             local t = tick()
  430.             if (t-mLastClickTime) < this.DoubleClickThreshold then
  431.                 --prvent multiple double-clicks in a row
  432.                 mLastClickTime = 0
  433.                 this.MouseDoubleClick:fire(mouse)
  434.             else
  435.                 mLastClickTime = t
  436.                 this.MouseClick:fire(mouse)
  437.             end
  438.         end)
  439.         mouse.Button1Up:connect(function()
  440.             this.MouseDown = false
  441.             this.MouseRelease:fire()
  442.         end)
  443.         mouse.KeyDown:connect(function(key)
  444.             this.KeyDown:fire(key)
  445.         end)
  446.  
  447.         --done setup, call the equipped function
  448.         if this.HUGE_EQUIP_HACK then
  449.             --the HUGE_EQUIP_HACK flags tells the tool that the equip is a synchronous
  450.             --call as a result of parenting an animation to the character, which happens
  451.             --when the tool is picked up from the workspace, but not during normal equips
  452.             --(Why does this happen???), if this is the case, the call should be rederrred
  453.             --one tick to ensure that all of the gear's loading can complete before it's
  454.             --equipped event is called.
  455.             --TODO: Blame John for this.
  456.             Delay(0, function()
  457.                 this.Equipped:fire(mouse)
  458.             end)
  459.         else
  460.             --otherwise, proceed as normal
  461.             this.Equipped:fire(mouse)
  462.         end
  463.     end)
  464.  
  465.     script.Parent.Unequipped:connect(function()
  466.         --before my teardown, fire the event
  467.         this.Unequipped:fire()
  468.  
  469.         --delete all my garbage
  470.         this.Bin:cleanAll()
  471.     end)
  472. end)
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521. local ChargeTime = 1 --1 second
  522.  
  523. Tool.AnimationProvider:registerAnimation('charge', 'http://www.roblox.com/asset/?id=69803963')
  524. Tool.AnimationProvider:registerAnimation('check', 'http://www.roblox.com/asset/?id=69803972')
  525. Tool.AnimationProvider:registerAnimation('equip', 'http://www.roblox.com/asset/?id=69803982')
  526. Tool.AnimationProvider:registerAnimation('stab', 'http://www.roblox.com/asset/?id=69803991')
  527.  
  528.  
  529. class'WeaponDamage'(nil, function(def)
  530.     local mDamage = 0
  531.     function def:setDamage(n)
  532.         mDamage = n
  533.     end
  534.     function def:getDamage()
  535.         return mDamage
  536.     end
  537. end)
  538.  
  539.  
  540. function FindHumanoid(part)
  541.     if not part.Parent then return end
  542.     if part.Parent:FindFirstChild("Humanoid") then
  543.         return part.Parent.Humanoid
  544.     elseif part.Parent.Parent and part.Parent.Parent:FindFirstChild("Humanoid") then
  545.         return part.Parent.Parent.Humanoid
  546.     end
  547. end
  548.  
  549.  
  550. local mGui = Create'ScreenGui'{
  551.     Name = "SpearGui",
  552.     Create'Frame'{
  553.         Name = "ChargeFrame",
  554.         Style = 'RobloxRound',
  555.         Size = UDim2.new(0, 256, 0, 32),
  556.         Position = UDim2.new(0.5, -128, 1, -128),
  557.         Create'Frame'{
  558.             Name = "ProgressBar",
  559.             Size = UDim2.new(0, 0, 1, 0),
  560.             BackgroundColor3 = Color3.new(0.8, 0.2, 0.2),
  561.         },
  562.         Create'TextLabel'{
  563.             Name = "ProgressLabel",
  564.             Size = UDim2.new(1, 0, 1, 0),
  565.             BackgroundTransparency = 1,
  566.             Font = 'Arial',
  567.             FontSize = 'Size18',
  568.             TextColor3 = Color3.new(0.8, 0.8, 0.8),
  569.             Text = "Click and hold to charge attack!",
  570.         }, 
  571.     },
  572. }
  573.  
  574.  
  575. function setProgress(frac)
  576.     frac = frac or 0
  577.     if frac == 0 then
  578.         mGui.ChargeFrame.ProgressLabel.Text = "Click and hold to charge attack!"
  579.     else
  580.         mGui.ChargeFrame.ProgressLabel.Text = "Charging "..(math.floor(frac*100)).."%"
  581.     end
  582.     mGui.ChargeFrame.ProgressBar.Size = UDim2.new(frac, 0, 1, 0)
  583. end
  584.  
  585.  
  586. local mDamageCn;
  587. local mCheckHitCn;
  588.  
  589.  
  590. local CurrentCharge = 0
  591. local Equipped = false
  592. local ClickNum = 0
  593. local Checking = false
  594. local CheckVelocity = 0
  595.  
  596.  
  597. Tool.MouseClick:connect(function()
  598.     ClickNum = ClickNum + 1
  599.     local thisClick = ClickNum
  600.     --
  601.     WeaponDamage:setDamage(25)
  602.     Tool.AnimationProvider:getAnimation('stab'):Play(0, 1, 4)
  603.     Delay(0.3, function()
  604.         if Equipped and Tool.MouseDown and ClickNum == thisClick then
  605.             WeaponDamage:setDamage(0)
  606.             --Imma charjin mah speeaar!!
  607.             Tool.AnimationProvider:getAnimation('charge'):Play(0, 1, 8)
  608.             Tool.Humanoid.WalkSpeed = 0
  609.             --
  610.             CurrentCharge = 0
  611.             local startCharge = tick()
  612.             while Tool.MouseDown do
  613.                 CurrentCharge = math.min(1, (tick()-startCharge)/ChargeTime)
  614.                 setProgress(CurrentCharge)
  615.                 wait()
  616.             end
  617.             setProgress()
  618.             --
  619.             Checking = true
  620.             Tool.Humanoid.WalkSpeed = 16
  621.             Tool.AnimationProvider:getAnimation('charge'):Stop(0)
  622.             Tool.AnimationProvider:getAnimation('check'):Play(0, 1, 8)
  623.             Tool.Humanoid.Jump = true
  624.             --
  625.             local torso = Tool.Character.Torso
  626.             local fly = Create'BodyVelocity'{
  627.                 velocity = torso.CFrame.lookVector*CurrentCharge*100,
  628.                 maxForce = Vector3.new(1000000, 0, 1000000),
  629.                 Parent = torso,
  630.             }
  631.             local forceDown = Create'BodyForce'{
  632.                 force = Vector3.new(0, -15000, 0),
  633.                 Parent = torso,
  634.             }
  635.             --
  636.             local footHitGroundCn;
  637.             local continueWait = true
  638.             if Tool.Character:FindFirstChild("Right Leg") then
  639.                 footHitGroundCn = Tool.Character["Right Leg"].Touched:connect(function(part)
  640.                     continueWait = false
  641.                 end)
  642.             end
  643.             local startJumpTime = tick()
  644.             while (tick()-startJumpTime) < 1 and continueWait do wait() end
  645.             Tool.AnimationProvider:getAnimation('check'):Stop()
  646.             if footHitGroundCn then
  647.                 footHitGroundCn:disconnect()
  648.             end
  649.             fly:Destroy()
  650.             forceDown:Destroy()
  651.             Delay(0.5, function()
  652.                 Checking = false
  653.             end)
  654.         else
  655.             wait(0.4)
  656.             if ClickNum == thisClick then
  657.                 WeaponDamage:setDamage(0)
  658.             end
  659.         end
  660.     end)
  661. end)
  662.  
  663.  
  664. Tool.Equipped:connect(function()
  665.     Tool.Handle = Tool.Tool.Handle
  666.     mGui.Parent = Tool.Player.PlayerGui
  667.     Tool.AnimationProvider:getAnimation('equip'):Play(0.1, 1, 3)
  668.     --
  669.     Equipped = true
  670.  
  671.     Delay(0, function()
  672.         --make a "tip" for the spear since only it's top should do damage
  673.         local tipPart = Create'Part'{
  674.             Name = "HandleTip",
  675.             Parent = Tool.Tool,
  676.             FormFactor = 'Custom',
  677.             CanCollide = false,
  678.             Transparency = 1,
  679.             Size = Vector3.new(0.7, 1.5, 0.7),
  680.         }
  681.         local tipWeld = Create'Weld'{
  682.             Name = "HandleTipWeld",
  683.             Parent = Tool.Handle,
  684.             Part0 = Tool.Handle,
  685.             C0 = CFrame.new(0, 2.8, 0),
  686.         }
  687.         tipWeld.Part1 = tipPart
  688.  
  689.         --add handling for damage
  690.         mDamageCn = tipPart.Touched:connect(function(part)
  691.             local hum = FindHumanoid(part)
  692.             if hum then
  693.                 TagHumanoid(hum)
  694.                 hum:TakeDamage(WeaponDamage:getDamage())
  695.             end
  696.         end)
  697.         mCheckHitCn = Tool.Handle.Touched:connect(function(part)
  698.             if Checking then
  699.                 local hum = FindHumanoid(part)
  700.                 if hum then
  701.                     local torso = hum.Parent:FindFirstChild("Torso")
  702.                     if torso then
  703.                         hum.Jump = true
  704.                         local myTorso = Tool.Character.Torso
  705.                         local fly = Create'BodyVelocity'{
  706.                             velocity = myTorso.CFrame.lookVector*CurrentCharge*120,
  707.                             maxForce = Vector3.new(1000000, 0, 1000000),
  708.                             Parent = torso,
  709.                         }
  710.                         Tool.Bin:add(function()
  711.                             fly:Destroy()
  712.                         end, 'kill-hit-fly')
  713.                         Delay(0.5, function()
  714.                             fly:Destroy()
  715.                         end)
  716.                     end
  717.                     TagHumanoid(hum)
  718.                     hum:TakeDamage(50*CurrentCharge)
  719.                 end
  720.             end
  721.         end)
  722.     end)
  723. end)
  724.  
  725.  
  726. Tool.Unequipped:connect(function()
  727.     mGui.Parent = nil
  728.     Tool.AnimationProvider:getAnimation('equip'):Stop(0)
  729.     Tool.AnimationProvider:getAnimation('stab'):Stop(0)
  730.     Tool.AnimationProvider:getAnimation('charge'):Stop(0)
  731.     Tool.AnimationProvider:getAnimation('check'):Stop(0)
  732.     --
  733.     Equipped = false
  734.     if mDamageCn then
  735.         mDamageCn:disconnect()
  736.         mCheckHitCn:disconnect()
  737.         mDamageCn = nil
  738.         mCheckHitCn = nil
  739.     end
  740. end)
  741. end))
  742. Script10.Name = "MotorizeRightGrip"
  743. Script10.Parent = LocalScript9
  744. table.insert(cors,sandbox(Script10,function()
  745. print("Run RightgripScript, parent=", script.Parent)
  746.  
  747. function Create(ty)
  748.     return function(data)
  749.         local obj = Instance.new(ty)
  750.         for k, v in pairs(data) do
  751.             if type(k) == 'number' then
  752.                 v.Parent = obj
  753.             else
  754.                 obj[k] = v
  755.             end
  756.         end
  757.         return obj
  758.     end
  759. end
  760.  
  761. local Tool = script.Parent.Parent
  762.  
  763. local armChildRemovedConn = nil
  764. local Motor6DGrip = nil
  765. local EquippedNum = 0
  766.  
  767. Tool.Equipped:connect(function()
  768.     EquippedNum = EquippedNum + 1
  769.     local myEquip = EquippedNum
  770.     --some vars
  771.     local Player = game.Players:GetPlayerFromCharacter(Tool.Parent)
  772.     local Character = Player.Character
  773.  
  774.     local rightarm = Character:FindFirstChild('Right Arm')
  775.     if rightarm and rightarm:FindFirstChild('RightGrip') then
  776.         local rightGrip = rightarm['RightGrip']
  777.         local handle = rightGrip.Part1
  778.  
  779.         --kill my joint when the normal joint is removed
  780.         --this must be done here so that the joint is removed
  781.         --_right away_ after unequipping and the character doesn't
  782.         --glitch up.
  783.         local armChildRemovedConn = rightarm.ChildRemoved:connect(function(ch)
  784.             if ch == rightGrip then
  785.                 if Motor6DGrip then
  786.                     Motor6DGrip:Remove()
  787.                     Motor6DGrip = nil
  788.                 end
  789.                 --
  790.                 if handle and Character:FindFirstChild('Torso') then
  791.                     if Tool.Parent.Parent:IsA('Player') then
  792.                         --the sword has been deselected
  793.                         --put the sword far away so the user doesn't notice that the handle doesn't
  794.                         --update for about 0.1 seconds after selecting the tool.
  795.                         handle.CFrame = CFrame.new(100000, 100000, 100000)
  796.                     else
  797.                         --if in the workspace, position the handle where it should be dropped
  798.                         --use the size of the handle to make sure it's dropped far enough away
  799.                         handle.CFrame = Character.Torso.CFrame * CFrame.new(0, 0, -(handle.Size.magnitude+2))
  800.                     end
  801.                 end
  802.             end
  803.         end)
  804.  
  805.         --make my new joint
  806.         Motor6DGrip = Create'Motor6D'{
  807.             Name = 'RightGrip_Motor',
  808.             Part0 = rightarm,
  809.             Part1 = handle,
  810.         }
  811.         --kill the old weld
  812.         rightGrip.Part1 = nil
  813.         rightGrip.Part0 = nil
  814.         Motor6DGrip.Parent = rightGrip.Parent
  815.     end
  816. end)
  817.  
  818. Tool.Unequipped:connect(function()
  819.     EquippedNum = EquippedNum + 1
  820.     if armChildRemovedConn then
  821.         armChildRemovedConn:disconnect()
  822.         armChildRemovedConn = nil
  823.     end
  824. end)
  825.  
  826. end))
  827. LocalScript11.Name = "MouseIcon"
  828. LocalScript11.Parent = Tool0
  829. table.insert(cors,sandbox(LocalScript11,function()
  830. --Made by Luckymaxer
  831.  
  832. Mouse_Icon = "rbxasset://textures/GunCursor.png"
  833. Reloading_Icon = "rbxasset://textures/GunWaitCursor.png"
  834.  
  835. Tool = script.Parent
  836.  
  837. Mouse = nil
  838.  
  839. function UpdateIcon()
  840.     if Mouse then
  841.         Mouse.Icon = Tool.Enabled and Mouse_Icon or Reloading_Icon
  842.     end
  843. end
  844.  
  845. function OnEquipped(ToolMouse)
  846.     Mouse = ToolMouse
  847.     UpdateIcon()
  848. end
  849.  
  850. function OnChanged(Property)
  851.     if Property == "Enabled" then
  852.         UpdateIcon()
  853.     end
  854. end
  855.  
  856. Tool.Equipped:Connect(OnEquipped)
  857. Tool.Changed:Connect(OnChanged)
  858.  
  859. end))
  860. Script12.Name = "SwordScript"
  861. Script12.Parent = Tool0
  862. table.insert(cors,sandbox(Script12,function()
  863. --Rescripted by Luckymaxer
  864. --EUROCOW WAS HERE BECAUSE I MADE THE PARTICLES AND THEREFORE THIS ENTIRE SWORD PRETTY AND LOOK PRETTY WORDS AND I'D LIKE TO DEDICATE THIS TO MY FRIENDS AND HI LUCKYMAXER PLS FIX SFOTH SWORDS TY LOVE Y'ALl
  865. --Updated for R15 avatars by StarWars
  866. --Re-updated by TakeoHonorable
  867.  
  868. Tool = script.Parent
  869. Handle = Tool:WaitForChild("Handle")
  870.  
  871. function Create(ty)
  872.     return function(data)
  873.         local obj = Instance.new(ty)
  874.         for k, v in pairs(data) do
  875.             if type(k) == 'number' then
  876.                 v.Parent = obj
  877.             else
  878.                 obj[k] = v
  879.             end
  880.         end
  881.         return obj
  882.     end
  883. end
  884.  
  885. local BaseUrl = "rbxassetid://"
  886.  
  887. Players = game:GetService("Players")
  888. Debris = game:GetService("Debris")
  889. RunService = game:GetService("RunService")
  890.  
  891. DamageValues = {
  892.     BaseDamage = 5,
  893.     SlashDamage = 10,
  894.     LungeDamage = 30
  895. }
  896.  
  897. --For R15 avatars
  898. Animations = {
  899.     R15Slash = 522635514,
  900.     R15Lunge = 522638767
  901. }
  902.  
  903. Damage = DamageValues.BaseDamage
  904.  
  905. Grips = {
  906.     Up = CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0),
  907.     Out = CFrame.new(0, 0, -1.70000005, 0, 1, 0, 1, -0, 0, 0, 0, -1)
  908. }
  909.  
  910. Sounds = {
  911.     Slash = Handle:WaitForChild("SwordSlash"),
  912.     Lunge = Handle:WaitForChild("SwordLunge"),
  913.     Unsheath = Handle:WaitForChild("Unsheath")
  914. }
  915.  
  916. ToolEquipped = false
  917.  
  918. --For Omega Rainbow Katana thumbnail to display a lot of particles.
  919. for i, v in pairs(Handle:GetChildren()) do
  920.     if v:IsA("ParticleEmitter") then
  921.         v.Rate = 20
  922.     end
  923. end
  924.  
  925. Tool.Grip = Grips.Up
  926. Tool.Enabled = true
  927.  
  928. function IsTeamMate(Player1, Player2)
  929.     return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
  930. end
  931.  
  932. function TagHumanoid(humanoid, player)
  933.     local Creator_Tag = Instance.new("ObjectValue")
  934.     Creator_Tag.Name = "creator"
  935.     Creator_Tag.Value = player
  936.     Debris:AddItem(Creator_Tag, 2)
  937.     Creator_Tag.Parent = humanoid
  938. end
  939.  
  940. function UntagHumanoid(humanoid)
  941.     for i, v in pairs(humanoid:GetChildren()) do
  942.         if v:IsA("ObjectValue") and v.Name == "creator" then
  943.             v:Destroy()
  944.         end
  945.     end
  946. end
  947.  
  948. function Blow(Hit)
  949.     if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped then
  950.         return
  951.     end
  952.     local RightArm = Character:FindFirstChild("Right Arm") or Character:FindFirstChild("RightHand")
  953.     if not RightArm then
  954.         return
  955.     end
  956.     local RightGrip = RightArm:FindFirstChild("RightGrip")
  957.     if not RightGrip or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~= Handle) then
  958.         return
  959.     end
  960.     local character = Hit.Parent
  961.     if character == Character then
  962.         return
  963.     end
  964.     local humanoid = character:FindFirstChildOfClass("Humanoid")
  965.     if not humanoid or humanoid.Health == 0 then
  966.         return
  967.     end
  968.     local player = Players:GetPlayerFromCharacter(character)
  969.     if player and (player == Player or IsTeamMate(Player, player)) then
  970.         return
  971.     end
  972.     UntagHumanoid(humanoid)
  973.     TagHumanoid(humanoid, Player)
  974.     humanoid:TakeDamage(Damage)
  975. end
  976.  
  977.  
  978. function Attack()
  979.     Damage = DamageValues.SlashDamage
  980.     Sounds.Slash:Play()
  981.  
  982.     if Humanoid then
  983.         if Humanoid.RigType == Enum.HumanoidRigType.R6 then
  984.             local Anim = Instance.new("StringValue")
  985.             Anim.Name = "toolanim"
  986.             Anim.Value = "Slash"
  987.             Anim.Parent = Tool
  988.         elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
  989.             local Anim = Tool:FindFirstChild("R15Slash")
  990.             if Anim then
  991.                 local Track = Humanoid:LoadAnimation(Anim)
  992.                 Track:Play(0)
  993.             end
  994.         end
  995.     end
  996. end
  997.  
  998. function Lunge()
  999.     Damage = DamageValues.LungeDamage
  1000.  
  1001.     Sounds.Lunge:Play()
  1002.    
  1003.     if Humanoid then
  1004.         if Humanoid.RigType == Enum.HumanoidRigType.R6 then
  1005.             local Anim = Instance.new("StringValue")
  1006.             Anim.Name = "toolanim"
  1007.             Anim.Value = "Lunge"
  1008.             Anim.Parent = Tool
  1009.         elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
  1010.             local Anim = Tool:FindFirstChild("R15Lunge")
  1011.             if Anim then
  1012.                 local Track = Humanoid:LoadAnimation(Anim)
  1013.                 Track:Play(0)
  1014.             end
  1015.         end
  1016.     end
  1017.     --[[
  1018.     if CheckIfAlive() then
  1019.         local Force = Instance.new("BodyVelocity")
  1020.         Force.velocity = Vector3.new(0, 10, 0)
  1021.         Force.maxForce = Vector3.new(0, 4000, 0)
  1022.         Debris:AddItem(Force, 0.4)
  1023.         Force.Parent = Torso
  1024.     end
  1025.     ]]
  1026.    
  1027.     wait(0.2)
  1028.     Tool.Grip = Grips.Out
  1029.     wait(0.6)
  1030.     Tool.Grip = Grips.Up
  1031.  
  1032.     Damage = DamageValues.SlashDamage
  1033. end
  1034.  
  1035. Tool.Enabled = true
  1036. LastAttack = 0
  1037.  
  1038. function Activated()
  1039.     if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
  1040.         return
  1041.     end
  1042.     Tool.Enabled = false
  1043.     local Tick = RunService.Stepped:wait()
  1044.     if (Tick - LastAttack < 0.2) then
  1045.         Lunge()
  1046.     else
  1047.         Attack()
  1048.     end
  1049.     LastAttack = Tick
  1050.     --wait(0.5)
  1051.     Damage = DamageValues.BaseDamage
  1052.     local SlashAnim = (Tool:FindFirstChild("R15Slash") or Create("Animation"){
  1053.         Name = "R15Slash",
  1054.         AnimationId = BaseUrl .. Animations.R15Slash,
  1055.         Parent = Tool
  1056.     })
  1057.    
  1058.     local LungeAnim = (Tool:FindFirstChild("R15Lunge") or Create("Animation"){
  1059.         Name = "R15Lunge",
  1060.         AnimationId = BaseUrl .. Animations.R15Lunge,
  1061.         Parent = Tool
  1062.     })
  1063.     Tool.Enabled = true
  1064. end
  1065.  
  1066. function CheckIfAlive()
  1067.     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)
  1068. end
  1069.  
  1070. function Equipped()
  1071.     Character = Tool.Parent
  1072.     Player = Players:GetPlayerFromCharacter(Character)
  1073.     Humanoid = Character:FindFirstChildOfClass("Humanoid")
  1074.     Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("HumanoidRootPart")
  1075.     if not CheckIfAlive() then
  1076.         return
  1077.     end
  1078.     ToolEquipped = true
  1079.     Sounds.Unsheath:Play()
  1080. end
  1081.  
  1082. function Unequipped()
  1083.     Tool.Grip = Grips.Up
  1084.     ToolEquipped = false
  1085. end
  1086.  
  1087. Tool.Activated:Connect(Activated)
  1088. Tool.Equipped:Connect(Equipped)
  1089. Tool.Unequipped:Connect(Unequipped)
  1090.  
  1091. Connection = Handle.Touched:Connect(Blow)
  1092. end))
  1093. for i,v in pairs(mas:GetChildren()) do
  1094.     v.Parent = script
  1095.     pcall(function() v:MakeJoints() end)
  1096. end
  1097. mas:Destroy()
  1098. for i,v in pairs(cors) do
  1099.     spawn(function()
  1100.         pcall(v)
  1101.     end)
  1102. end
Advertisement
Add Comment
Please, Sign In to add comment