Advertisement
Reactor4

aaewqewq

Mar 1st, 2021
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.72 KB | None | 0 0
  1. Properties = {
  2.     debounce = true, -- Leave this on true.
  3.     sound_fx = true, -- If you don't want sound to play when tool is activated set this to false.
  4.     anim_check = true, -- If you don't want animation to play when tool is activated set this to false.
  5.     ToolDrop = false, -- Set this to true if you want to be able to drop the tool by pressing BackSpace.
  6.     soundID = 6042531284, -- Sound Id.
  7.     AnimID = 6461572129, -- Your Animtion id.
  8.     debounce_lenght = 1, -- how long it will take before you can click again, aka cooldown so you can't spam click the tool.
  9.     soundDelay = 0.25, -- How long to wait before playing sound
  10.     enableTrail = true, -- Enable trail thing
  11.     trail = script.Parent.Head.Trail, -- the trail thing
  12.     damage = 5 -- how much dmg the thing does
  13. }
  14.  
  15. local Tool = script.Parent
  16. local Handle = Tool:WaitForChild("Handle")
  17. local BaseUrl = "rbxassetid://"
  18. local anim = Tool:WaitForChild("Animation")
  19. local Players = game:GetService("Players")
  20.  
  21.  
  22. if Properties.sound_fx then
  23.     sound = Handle:WaitForChild("Sound")
  24.     sound.SoundId = BaseUrl .. Properties.soundID
  25.     sound.MaxDistance = 100
  26.     sound.RollOffMode = Enum.RollOffMode.InverseTapered
  27. end
  28.  
  29.  
  30.  
  31. if Properties.anim_check then  
  32.     anim.AnimationId = BaseUrl .. Properties.AnimID
  33. end
  34.  
  35.  
  36. if Properties.ToolDrop == true then
  37.     Tool.CanBeDropped = true
  38. end
  39.  
  40. Tool.Equipped:Connect(function(Mouse) -- When you equip the tool
  41.     local player = Players:GetPlayerFromCharacter(Tool.Parent) -- gets the player
  42.     if Properties.anim_check == true then animation = player.Character.Humanoid:LoadAnimation(anim)end -- loads animation
  43.  
  44.     Tool.Activated:Connect(function() -- when you click with the tool
  45.         if Properties.debounce then
  46.             Properties.debounce = false
  47.             if Properties.anim_check == true then animation:Play()end
  48.             if Properties.sound_fx == true then wait(Properties.soundDelay) sound:Play()end
  49.  
  50.             if Properties.enableTrail == true then
  51.                 Properties.trail.Enabled = true
  52.                 wait(0.2)
  53.                 Properties.trail.Enabled = false
  54.             end
  55.            
  56.             local debounce = false
  57.             script.Parent.Head.Touched:Connect(function(Hit)
  58.                 --print(Hit.Name)
  59.                 if Hit:FindFirstChildWhichIsA("NumberValue") and Hit:FindFirstChildWhichIsA("NumberValue").Name == "Health" then   
  60.                     local temp = Hit:FindFirstChildWhichIsA("NumberValue")
  61.                     --print(temp.Name .. ": " .. temp.Value)
  62.                     if debounce == false then
  63.                         debounce = true
  64.                         temp.Value = temp.Value - Properties.damage
  65.                         wait(1.2)
  66.                         debounce = false
  67.                     end
  68.                    
  69.                 end
  70.             end)
  71.  
  72.             wait(Properties.debounce_lenght)   
  73.             Properties.debounce = true
  74.         end
  75.     end)
  76. end)
  77. Tool.Unequipped:Connect(function()
  78.     if Properties.anim_check == true then animation:Stop()end
  79.     if Properties.sound_fx then sound:Stop()end
  80. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement