Advertisement
killerbrenden

Untitled

Oct 13th, 2020
1,923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. local ModuleScript = require(script.Parent.ModuleScript)
  2.  
  3. local HitsNeeded = 5
  4. local Range = 10
  5. local ReloadTime = 0.5
  6. local Hits = ModuleScript.Hits
  7.  
  8. local canMine = false
  9.  
  10. local player = game:GetService("Players").LocalPlayer
  11. local mouse = player:GetMouse()
  12.  
  13. local character = player.Character or player.CharacterAdded:Wait()
  14. local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
  15. local humanoid = character:WaitForChild("Humanoid")
  16.  
  17. script.Parent.Equipped:Connect(function()
  18.     canMine = true
  19. end)
  20.  
  21. script.Parent.Unequipped:Connect(function()
  22.     canMine = false
  23. end)
  24.  
  25. script.Parent.Activated:Connect(function()
  26.     if mouse.Target and canMine then
  27.         local dist = (humanoidRootPart.Position - mouse.Target.Position).Magnitude
  28.         if mouse.Target.Parent.Name == "Mine" and dist <= Range then
  29.             if Hits <= HitsNeeded then
  30.                 canMine = false
  31.                 Hits += 1
  32.                 script.Mine:Play()
  33.                 wait(ReloadTime)
  34.                 script.Mine:Pause()
  35.                 canMine = true
  36.             else
  37.                 canMine = false
  38.                 Hits = 1
  39.                 mouse.Target:Destroy()
  40.                 script.Collecting:Play()
  41.                 wait(ReloadTime)
  42.                 script.Mine:Pause()
  43.                 canMine = true
  44.             end
  45.         end
  46.     end
  47. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement