Advertisement
Guest User

Rewrite

a guest
Apr 6th, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. local replicatedStorage = game:GetService("ReplicatedStorage")
  2. local killEvent = replicatedStorage:WaitForChild("KillEvent")
  3.  
  4. local players = game:GetService("Players")
  5. local player = players.LocalPlayer
  6.  
  7. local tool = script.Parent
  8. local handle = tool:WaitForChild("Handle")
  9.  
  10. local toolSounds = tool:WaitForChild("Sounds")
  11. local equipSound = toolSounds:WaitForChild("Equip")
  12. local slashSound = toolSounds:WaitForChild("Slash")
  13. local killSound = toolSounds:WaitForChild("Kill")
  14.  
  15. local animations = tool:WaitForChild("Animations")
  16. local knifeHoldAnimation = animations:WaitForChild("KnifeHold")
  17.  
  18. local debounce = false
  19.  
  20. tool.Equipped:Connect(function(Cursor) equipSound:Play()
  21.         Cursor.Icon = "rbxasset://textures/GunCursor.png"
  22.     local character = player.Character or player.CharacterAdded:Wait()
  23.     local humanoid = character:WaitForChild("Humanoid")
  24.     local knifehold = humanoid:LoadAnimation(knifeHoldAnimation); knifeHold:Play()
  25.     tool.Activated:Connect(function()
  26.         if (debounce) then return end; debounce = true
  27.             local randomAnimation = Random.new(tick):NextInteger(1,3)
  28.             local slashAnimation = animations["Slash"..randomAnimation]
  29.             local slash = humanoid:LoadAnimation(slashAnimation); slash:Play()
  30.             slashsound:Play()
  31.             debounce = false
  32.         end
  33.     end)
  34. end)
  35.  
  36. handle.Touched:Connect(function(hit)
  37.     if (hit.Parent == player.Character) then return end
  38.     local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
  39.     if (humanoid) then
  40.             if (humanoid:GetState ~= Enum.HumanoidStateType.Dead) then
  41.                 killEvent:FireServer(hit.Parent)
  42.             killSound:Play()
  43.         end
  44.     end
  45. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement