I made a tool (a pickaxe) with which you click on specific parts, and after 10 seconds, they get moved to ReplicatedStorage (mined) and regenerate after 15 seconds. I’m just interested to know if there’s some cool tips or tricks I could do to make my code neater. As I said, I’m fairly new (been learning for around a week now), I did look at tutorials and ask for help and stuff, but I didn’t just copy-paste, I understand how and why this works.
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local debounce = false
local nodes = {"StoneNode","CoalNode"}
function isEquipped()
if tool.Parent.Name ~= "Backpack" then
return true
else
return false
end
end
mouse.Button1Down:Connect(function()
local inventoryGui = plr.PlayerGui.Main.Inventory
if isEquipped() and not debounce then
local target = mouse.Target
for i, v in pairs(nodes) do
if target.Name == v then
debounce = true
--Stone Node Mined
if v == "StoneNode" then
for i = 10, 1, -1 do
print(i)
wait(1)
if i == 1 then
target.Parent = game.ReplicatedStorage
--WIP
end
end
--Regenerating
delay(15, function()
target.Parent = game.Workspace
end)
end
--Coal Node Mined
if v == "CoalNode" then
for i = 10, 1, -1 do
print(i)
wait(1)
if i == 1 then
target.Parent = game.ReplicatedStorage
--WIP
end
end
--Regenerating
delay(15, function()
target.Parent = game.Workspace
end)
end
debounce = false
end
end
end
end)