OK for the first script ( localscript ) it is in Starterpack. The I set the time to 2 for testing it out faster and the tree still wont regenerate.
repeat wait() until game.Players.LocalPlayer.Character local Plr = game.Players.LocalPlayer local Char = Plr.Character or Plr.CharacterAdded:Wait() local Mouse = Plr:GetMouse() local CouldGetWood = true local TreeCutDown = false local Treee = game.Workspace.Tree 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 TreeCutDown = true 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() TreeCutDown = true WC.BG.Visible = false CouldGetWood = true end end end) while wait(2) and TreeCutDown == true do --Runs every 60 seconds and checks if the trees were cut down game.ReplicatedStorage.TreeSpawner:FireServer(Treee, "Name", Vector3.new(505, 30.546, 90.298), game.Workspace.Tree)--Change the game.Workspace.TreesModel to whatever you want, just make sure its in the workspace TreeCutDown = false end
Now for the second script that is also in Starter pack but it is a regular script ( not localscript ) I'm getting this error for that script, 14:44:57.830 - TreeSpawner is not a valid member of ReplicatedStorage, I dont know if this error affects the first script of the respawning. Here is the second script.
game.ReplicatedStorage.TreeSpawner.OnServerEvent:Connect(function(Player, Object,name, Position, Place) local Tree = Object:Clone() --Clones the tree Tree.Name = name Tree.Parent = Place Tree.Position = Vector3.new(Position) end)
First we need to make a variable to check if the tree has been cut down to prevent multiple trees at the same place: Also make sure to go to ReplicatedStorage and add a "RemoteEvent" and name it TreeSpawner
repeat wait() until game.Players.LocalPlayer.Character local Plr = game.Players.LocalPlayer local Char = Plr.Character or Plr.CharacterAdded:Wait() local Mouse = Plr:GetMouse() local CouldGetWood = true local TreeCutDown = false --Is the tree cut down? 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 TreeCutDown = true --The tree was cut down and set the value to true 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() TreeCutDown = true--The tree was cut down and set the value to true WC.BG.Visible = false CouldGetWood = true end end end)
After that we will make a while loop that'll check if the tree was cut down..
repeat wait() until game.Players.LocalPlayer.Character local Plr = game.Players.LocalPlayer local Char = Plr.Character or Plr.CharacterAdded:Wait() local Mouse = Plr:GetMouse() local CouldGetWood = true local TreeCutDown = false 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 TreeCutDown = true 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() TreeCutDown = true WC.BG.Visible = false CouldGetWood = true end end end) while wait(60) and TreeCutDown == true do --Runs every 60 seconds and checks if the trees were cut down game.ReplicatedStorage.TreeSpawner:FireServer(Wood, "Name", Vector3.new(Position), game.Workspace.TreesModel)--Change the game.Workspace.TreesModel to whatever you want, just make sure its in the workspace TreeCutDown = false end
and in another script, make sure its a SERVER SCRIPT, the scripts that are blue colored
game.ReplicatedStorage.TreeSpawner.OnServerEvent:Connect(function(Player, Object,name, Position, Place) local Tree = Object:Clone() --Clones the tree Tree.Name = name Tree.Parent = Place Tree.Position = Vector3.new(Position) end)