So I made a tree in roblox that you can break so far and the part dissapears. I want to make it regenerate after about a minute. Here is the script. How would I do this? I see a lot of people have regenerating buttons and I would like to make a tree that regenerates at 60 seconds, Im aware you have to do something with wait (60) and some position stuff but I have no clue after that
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Mouse = Plr:GetMouse()
local CouldGetWood = true
function ShowProgress(tree)
if tree == "Tree" then
for i = 0,1,.01 do
WC.BG.Bar.Progress.Size = UDim2.new(i,0,1,0)
wait()
end
elseif tree == "HardTree" then
for i = 0,1,.005 do
WC.BG.Bar.Progress.Size = UDim2.new(i,0,1,0)
wait()
end
end
end
Mouse.Button1Down:connect(function()
if Mouse.Target ~= nil and Mouse.Target.Parent.Name == "Tree" and CouldGetWood == true then
local Wood = Mouse.Target
if (Wood.Position - Char.UpperTorso.Position).magnitude < 10 then
CouldGetWood = false
WC = Plr.PlayerGui.WoodChopper
WC.BG.Visible = true
Char.Humanoid.WalkSpeed = 0
ShowProgress ("Tree")
Char.Humanoid.WalkSpeed = 16
for i,v in pairs(Wood.Parent.Leaves:GetChildren())do
if v:IsA("Part") then
v.Anchored = false
end
end
Wood:Destroy()
WC.BG.Visible = false
CouldGetWood = true
end
end
if Mouse.Target ~= nil and Mouse.Target.Parent.Name == "HardTree" and CouldGetWood == true then
local Wood = Mouse.Target
if (Wood.Position - Char.Torso.Position).magnitude < 10 then
CouldGetWood= false
WC = Plr.PlayerGui.WoodChopper
WC.BG.Visible = true
Char.Humanoid.WalkSpeed = 0
ShowProgress ("HardTree")
Char.Humanoid.WalkSpeed = 16
for i,v in pairs(Wood.Parent.Leaves:GetChildren())do
if v:IsA("Part") then
v.Anchored = false
end
end
Wood:Destroy()
WC.BG.Visible = false
CouldGetWood = true
end
end
end)```