Advertisement
Guest User

Knife Script

a guest
Mar 24th, 2020
10,228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. --//Local Script
  2. local last = 0
  3. local cooldown = 1
  4. local swinging = script.Parent:WaitForChild("Swinging")
  5. local canbekilled = script.Parent.CanBeKilled
  6. script.Parent.Equipped:Connect(function(t)
  7.     t.Button1Down:Connect(function()
  8.         if tick() - last > cooldown then
  9.             last = tick()
  10.         local a = script.Parent.Animation
  11.         local plr = game.Players.LocalPlayer
  12.         local char = plr.Character
  13.         local hum = char:FindFirstChild("Humanoid")
  14.         local animation = hum:LoadAnimation(a)
  15.         canbekilled:FireServer(swinging, cooldown, last)
  16.         animation:Play()
  17.         end
  18.     end)
  19. end)
  20.  
  21. --//Server Script
  22. script.Parent.Parent.CanBeKilled.OnServerEvent:Connect(function(player, swinging)
  23.     swinging.Value = true
  24.     local last = 0
  25.     local cooldown = 2
  26. script.Parent.Parent.Equipped:Connect(function()
  27.    
  28.     local tool = script.Parent.Parent
  29.    
  30.     local char = tool.Parent
  31.     local plr = game.Players:GetPlayerFromCharacter(char)
  32.     print(plr.Name.." has equipped"..tool.Name)
  33.    
  34.     script.Parent.Touched:Connect(function(hitbox)
  35.     if tick() - last > cooldown then
  36.         last = tick()
  37.     if swinging.Value == true then
  38.        
  39.     if hitbox.name == "HitBox" then
  40.         local hum = hitbox.Parent:FindFirstChild("Humanoid")
  41.         hum.Health = 0
  42.         print("Kill Enabled")
  43.     end
  44.    
  45.     end
  46.     end
  47.     end)
  48. end)
  49.     end)
  50.        
  51.        
  52.         while wait(2) do
  53.             local swinging = script.Parent.Parent.Swinging
  54.             swinging.Value = false
  55.         end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement