Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ModuleScript = require(script.Parent.ModuleScript)
- local HitsNeeded = 5
- local Range = 10
- local ReloadTime = 0.5
- local Hits = ModuleScript.Hits
- local canMine = false
- local player = game:GetService("Players").LocalPlayer
- local mouse = player:GetMouse()
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- local humanoid = character:WaitForChild("Humanoid")
- script.Parent.Equipped:Connect(function()
- canMine = true
- end)
- script.Parent.Unequipped:Connect(function()
- canMine = false
- end)
- script.Parent.Activated:Connect(function()
- if mouse.Target and canMine then
- local dist = (humanoidRootPart.Position - mouse.Target.Position).Magnitude
- if mouse.Target.Parent.Name == "Mine" and dist <= Range then
- if Hits <= HitsNeeded then
- canMine = false
- Hits += 1
- script.Mine:Play()
- wait(ReloadTime)
- script.Mine:Pause()
- canMine = true
- else
- canMine = false
- Hits = 1
- mouse.Target:Destroy()
- script.Collecting:Play()
- wait(ReloadTime)
- script.Mine:Pause()
- canMine = true
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement