When the ore (part) gets mined it will get destroyed by line 42, how do I make it respawn after 60 seconds?
local pickaxe = script.Parent
local head = pickaxe:WaitForChild("Head")
local mouseHeldRE = pickaxe:WaitForChild("MouseHeldEvent")
local mouseHeld = false
local coolingDown = false
mouseHeld = isHeld
if not mouseHeld or coolingDown then return end
coolingDown = true
local blockStrength = hitPart:FindFirstChild("HitsToBreak")
if blockStrength then
blockStrength.Value = blockStrength.Value - 1
if blockStrength.Value <= 0 then
local plr = game.Players:GetPlayerFromCharacter(pickaxe.Parent)
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + hitPart.CashReward.Value
coolingDown = false
What you’ll want to use is task.delay:
-- respawn code
simply move it to server/replicatedstorage when it gets ‘mined’, add a
wait(60), and then return it to workspace.
Where would I add the wait(60) in the script?
coolingdown = false should work as you want
How do I move it to server storage when mined? and is there a youtube video on how to do it
If you do not know the answer to this question, you should really really consider looking through basic tutorials/intros to roblox scripting.
You set the
.Parent property of the brick to
game:GetService("ServerStorage") - keep in mind you have to use replicatedstorage in the case it’d be a localscript.
Assuming the script would clone from the games storage, you can just make the script delete the part that is touchable, then clone the part from the games storage, then the script will delete the parent leaving you with a new clone part after 60 seconds.
Reusing the same model, like changing it’s parents back and forth, may cause problems but that’ll also work instead of just destroying the part too.
You could try using something along the lines of
while true do
if not workspace:FindFirstChild(“partname”) then
—put some code here