So i'm trying to make a pickaxe mine away at ores - Which works perfectly... However, if you activate the tool and it doesn't hit anything, it doesn't let you hit again until it touches something... Then if it touches one of the ores, it gives it to them without clicking to mine it...
Any ideas?
game.ReplicatedStorage.Whack.OnServerEvent:Connect(function(player)
local playersname = player.Name
local FolderName = game.ServerScriptService:FindFirstChild(playersname)
if FolderName then
if FolderName.Pickaxe.Value == false then
FolderName.Pickaxe.Value = true
local kickAnimation = Instance.new("Animation")
kickAnimation.AnimationId = "rbxassetid://704173649"
local kickAnimationTrack = player.Character.Humanoid:LoadAnimation(kickAnimation)
kickAnimationTrack:Play()
local Debounce = false
function Stabby(hit)
if hit.Name == nil then
print("GRR")
wait(1)
elseif hit.Name ~= nil and Debounce == false then
print(hit)
if hit.Parent.Name == "Rock" then
Debounce = true
FolderName.Stone.Value = FolderName.Stone.Value +1
print(FolderName.Stone.Value)
player.PlayerGui.Inventory.Raw.Stone.Text = "Stone: ".. FolderName.Stone.Value
wait(3)
FolderName.Pickaxe.Value = false
elseif hit.Parent.Name == "Gold" then
Debounce = true
FolderName.Gold.Value = FolderName.Gold.Value +1
print(FolderName.Gold.Value)
player.PlayerGui.Inventory.Raw.Gold.Text = "Gold: ".. FolderName.Gold.Value
wait(3)
FolderName.Pickaxe.Value = false
elseif hit.Parent.Name == "Copper" then
Debounce = true
FolderName.Copper.Value = FolderName.Copper.Value +1
print(FolderName.Copper.Value)
player.PlayerGui.Inventory.Raw.Copper.Text = "Copper: ".. FolderName.Copper.Value
wait(3)
FolderName.Pickaxe.Value = false
elseif hit.Parent.Name == "Iron" then
Debounce = true
FolderName.Iron.Value = FolderName.Iron.Value +1
print(FolderName.Iron.Value)
player.PlayerGui.Inventory.Raw.Iron.Text = "Iron: ".. FolderName.Iron.Value
wait(3)
FolderName.Pickaxe.Value = false
elseif hit.Parent.Name == "Tin" then
Debounce = true
FolderName.Tin.Value = FolderName.Tin.Value +1
print(FolderName.Tin.Value)
player.PlayerGui.Inventory.Raw.Tin.Text = "Tin: ".. FolderName.Tin.Value
wait(3)
FolderName.Pickaxe.Value = false
elseif hit.Parent.Name == "Coal" then
Debounce = true
FolderName.Coal.Value = FolderName.Coal.Value +1
print(FolderName.Coal.Value)
player.PlayerGui.Inventory.Raw.Coal.Text = "Coal: ".. FolderName.Coal.Value
wait(3)
FolderName.Pickaxe.Value = false
elseif hit.Parent.Name == "Clay" then
Debounce = true
FolderName.Clay.Value = FolderName.Clay.Value +1
print(FolderName.Clay.Value)
player.PlayerGui.Inventory.Raw.Clay.Text = "Clay: ".. FolderName.Clay.Value
wait(3)
FolderName.Pickaxe.Value = false
else
FolderName.Pickaxe.Value = false
end
end
end
player.Character.Pickaxe.Handle.Touched:connect(Stabby)
end
end
end)
Thank you.
