codemen

Knife script [roblox]

Nov 12th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.55 KB | None | 0 0
  1. --Knife script by DMS
  2. --Just a regular knife script
  3. OOHNELLY = Instance.new("Tool")
  4. NELLAY = Instance.new("Animation")
  5. NOTSEEEE = Instance.new("Part")
  6. LEECHYISHERE = Instance.new("Sound")
  7. SPECIALMESHXDDDD = Instance.new("SpecialMesh")
  8. SEIGHEIL = Instance.new("Sound")
  9. OOHNELLY.Name = "Knife"
  10. OOHNELLY.Parent = game.Players.LocalPlayer.Backpack
  11. OOHNELLY.GripForward = Vector3.new(-1.74845553e-007, 4.37113812e-008, 1)
  12. OOHNELLY.GripPos = Vector3.new(0.487703323, -3.7742065e-010, 0.00863459334)
  13. OOHNELLY.GripRight = Vector3.new(-7.64274186e-015, -1, 4.37113812e-008)
  14. OOHNELLY.GripUp = Vector3.new(-1, 0, -1.74845553e-007)
  15. OOHNELLY.CanBeDropped = false -- no removal unless you wanna shank urself
  16. NELLAY.Name = "Whack"
  17. NELLAY.Parent = OOHNELLY
  18. NELLAY.AnimationId = "http://www.roblox.com/Asset?ID=94161088"
  19. NOTSEEEE.Name = "Handle"
  20. NOTSEEEE.Parent = OOHNELLY
  21. NOTSEEEE.BrickColor = BrickColor.new("Really black")
  22. NOTSEEEE.Reflectance = 0.0099999997764826
  23. NOTSEEEE.Position = Vector3.new(-5.70826387, 0.254999995, 10.8100071)
  24. NOTSEEEE.Size = Vector3.new(1.54999995, 0.50999999, 0.699999988)
  25. NOTSEEEE.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  26. LEECHYISHERE.Name = "Swoosh"
  27. LEECHYISHERE.Parent = NOTSEEEE
  28. LEECHYISHERE.Pitch = 3
  29. LEECHYISHERE.SoundId = "http://www.roblox.com/asset?id=153647529"
  30. LEECHYISHERE.Volume = 1
  31. LEECHYISHERE.PlayOnRemove = true
  32. SPECIALMESHXDDDD.Parent = NOTSEEEE
  33. SPECIALMESHXDDDD.MeshId = "rbxassetid://442337985"
  34. SPECIALMESHXDDDD.Offset = Vector3.new(-0.600000024, 0, -0.200000003)
  35. SPECIALMESHXDDDD.Scale = Vector3.new(0.300000012, 0.300000012, 0.300000012)
  36. SPECIALMESHXDDDD.TextureId = "rbxassetid://442337993"
  37. SPECIALMESHXDDDD.MeshType = "FileMesh"
  38. SEIGHEIL.Name = "Ting"
  39. SEIGHEIL.Parent = NOTSEEEE
  40. SEIGHEIL.SoundId = "rbxassetid://429400881"
  41. SEIGHEIL.Volume = 0.20000000298023
  42. OOHNELLY = OOHNELLY
  43. Handle = OOHNELLY:WaitForChild("Handle")
  44.  
  45. Players = game:GetService("Players")
  46. Debris = game:GetService("Debris")
  47. InsertService = game:GetService("InsertService")
  48.  
  49. WhackAnim = OOHNELLY:WaitForChild("Whack")
  50. SlashSound = Handle:WaitForChild("Swoosh")
  51. HitSound = Handle:WaitForChild("Ting")
  52.  
  53. Damage = 100 --the damage dealt
  54.  
  55. ReloadTime = 1.45 --time between each swing
  56.  
  57. Kills = 0 --start off with 0 killstreak
  58.  
  59. function TagHumanoid(humanoid, player) --registers you actually hitting the guy
  60. HitSound:Play()
  61. local Creator_Tag = Instance.new("ObjectValue")
  62. Creator_Tag.Name = "creator"
  63. Creator_Tag.Value = player
  64. Debris:AddItem(Creator_Tag, 2)
  65. Creator_Tag.Parent = humanoid
  66. end
  67.  
  68. function UntagHumanoid(humanoid) --removes the tag so that if someone kills the person you tagged, it doesnt register you killing that person.
  69. for i, v in pairs(humanoid:GetChildren()) do
  70. if v:IsA("ObjectValue") and v.Name == "creator" then
  71. v:Destroy()
  72. end
  73. end
  74. end
  75.  
  76. function Blow(Hit) --registers the hit, deals damage to the player, and if the humanoid has 0 health a kill is added into the killstreak.
  77. if Hit and Hit.Parent then
  78. local character = Hit.Parent
  79. local humanoid = character:FindFirstChild("Humanoid")
  80. if Humanoid and Humanoid ~= humanoid and humanoid and Humanoid.Health > 0 and humanoid.Health > 0 then
  81. local Right_Arm = Character:FindFirstChild("Right Arm")
  82. if Right_Arm then
  83. local Joint = Right_Arm:FindFirstChild("RightGrip")
  84. if (Joint and (Joint.Part0 == Handle or Joint.Part1 == Handle)) then
  85. humanoid:TakeDamage(Damage) --deal regular damage or instakill normal health players if a ninja
  86. UntagHumanoid(humanoid)
  87. TagHumanoid(humanoid, Player)
  88. end
  89. end
  90. end
  91. end
  92. end
  93.  
  94. function Activated() --when you swing
  95. if OOHNELLY.Enabled then
  96. OOHNELLY.Enabled = false
  97. Whack = Humanoid:LoadAnimation(WhackAnim)
  98. if Whack then
  99. Whack:Play()
  100. SlashSound:Play()
  101. wait(.6)
  102. Whack:Stop()
  103. end
  104. OOHNELLY.Enabled = true
  105. end
  106. end
  107.  
  108. function Equipped(mouse) --get everything settled up
  109. Character = OOHNELLY.Parent
  110. Player = Players:GetPlayerFromCharacter(Character)
  111. Humanoid = Character:FindFirstChild("Humanoid")
  112. Torso = Character:FindFirstChild("Torso")
  113. if not Humanoid or not Torso then
  114. return
  115. end
  116.  
  117. if not OOHNELLY.Enabled then
  118. wait(ReloadTime)
  119. OOHNELLY.Enabled = true
  120. end
  121. end
  122.  
  123. function Unequipped()
  124. if Whack then
  125. Whack:Stop() --stop the swing anim so we dont get stuck
  126. end
  127. end
  128.  
  129. --important stuff to register what is what. you need these if you want to do stuff with the OOHNELLY itself.
  130. OOHNELLY.Activated:connect(Activated)
  131. OOHNELLY.Equipped:connect(Equipped)
  132. OOHNELLY.Unequipped:connect(Unequipped)
  133.  
  134. Handle.Touched:connect(Blow)
Add Comment
Please, Sign In to add comment