My Woodcutting Script has a strange error, I can make it chop 2x faster

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Implemented AutoChopper.

  2. What is the issue? Include screenshots / videos if possible!

This is how it should work…

https://gyazo.com/eb055414ef923adad7e769a824769d83

and then this is what I can do to make the bug happen

https://gyazo.com/33c2e69c7ad4fef4cbf72b9ecd921c01

The outcome is this…

https://gyazo.com/13c66cdce8b38601ebd6ae0f6708dcd9

Any ideas why it is doing the loop more than once?

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

There isn’t really any solutions on the developer hub since it’s my own script etc, and I’m just lost and stuck i’m not sure if it’s the debouncers or not, or the way the debouncers reset…

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

I’ve got it so if the magnitude is greater than 28 from the player and the tree then it will reset my debouncers and take the hatchet and stuff off

			elseif args[2] == 'Reset Debouncers' then
				task.wait();
				Clicked = false;
				ClickedBoss = false;
				RunningAutoChopper = false;
			end

i’ve tried waits and everything it just doesn’t work, without the autochopper I can’t physically chop twice so it’s something to do with the loop,

FYI I had a while loop at the start and then I changed to a Repeat to see if it would make a difference but it didn’t do anything. task.wait also was wait()

The Chopping Part…

ClickDetector.MouseClick:connect(function(c)
	for i,v in pairs(plr.PlayerGui:GetChildren()) do
		if v.Name == "TreeUI" then
			v:Destroy();
		end
	end

	if not Clicked and ClickDetector.Parent.Transparency == 0 and string.match(ClickDetector.Parent.Name, c.Name) and not args[3] then
		Clicked = true;
		if not Chopped and Clicked then
			Chopped = true;
			remote:FireServer("Woodcutting", "GiveAXE", ClickDetector.Parent)
			remote:FireServer("Woodcutting", "Chop", ClickDetector.Parent)
			remote:FireServer("Woodcutting", "TreeDistance", ClickDetector.Parent)
		end
		task.wait(3)
		Clicked = false;		
		Chopped = false;
		elseif not Clicked and ClickDetector.Parent.Transparency == 0 and ClickDetector.Parent.Name == "EverGreen" then -- this Argument only runs once
			Clicked = true;
			if args[3] and not RunningAutoChopper and Clicked then -- This runs once.
				RunningAutoChopper = true;
				task.wait()
				repeat -- This if i reset debouncers from distance of 28 >= i can click tree and it will chop 2x faster but this only calls once...
				if string.match(ClickDetector.Parent.Name, c.Name) then
				else
					remote:FireServer("Woodcutting", "NameChanger", ClickDetector.Parent)
				end
				remote:FireServer("Woodcutting", "GiveAXE", ClickDetector.Parent)
				remote:FireServer("Woodcutting", "Chop", ClickDetector.Parent)
				remote:FireServer("Woodcutting", "TreeDistance", ClickDetector.Parent)
				task.wait(3)
				until RunningAutoChopper == false;

A Server Event That gets called which is the Tree Distance function.

elseif args[2] == "TreeDistance" then
					if not PlayerStatManager:ReturnPlayer(client).GotLoop then
						PlayerStatManager:ReturnPlayer(client).GotLoop = true;
						local function DeleteHatchetGiven()
							if PlayerStatManager:ReturnPlayer(client).DEFAxeW then
								for i,v in pairs(client.Character:GetChildren()) do
									if v == client.Character:FindFirstChild("Default Hatchet") then
										v:Destroy()
									end
								end
							elseif PlayerStatManager:ReturnPlayer(client).FAxeW then
								for i,v in pairs(client.Character:GetChildren()) do
									if v == client.Character:FindFirstChild("Fire Hatchet") then
										v:Destroy()
									end
								end
							elseif PlayerStatManager:ReturnPlayer(client).SAxeW then
								for i,v in pairs(client.Character:GetChildren()) do
									if v == client.Character:FindFirstChild("Smoke Hatchet") then
										v:Destroy()
									end
								end
							elseif PlayerStatManager:ReturnPlayer(client).IAxeW then
								for i,v in pairs(client.Character:GetChildren()) do
									if v == client.Character:FindFirstChild("Invisible Hatchet") then
										v:Destroy()
									end
								end
							elseif PlayerStatManager:ReturnPlayer(client).NAxeW then
								for i,v in pairs(client.Character:GetChildren()) do
									if v == client.Character:FindFirstChild("Neon Hatchet") then
										v:Destroy()
									end
								end
							elseif PlayerStatManager:ReturnPlayer(client).DAxeW then
								for i,v in pairs(client.Character:GetChildren()) do
									if v == client.Character:FindFirstChild("Diamond Hatchet") then
										v:Destroy()
									end
								end
							elseif PlayerStatManager:ReturnPlayer(client).CAxeW then
								for i,v in pairs(client.Character:GetChildren()) do
									if v == client.Character:FindFirstChild("Carrot Hatchet") then
										v:Destroy()
									end
								end
							elseif PlayerStatManager:ReturnPlayer(client).EAxeW then
								for i,v in pairs(client.Character:GetChildren()) do
									if v == client.Character:FindFirstChild("Earth Hatchet") then
										v:Destroy()
									end
								end
							elseif PlayerStatManager:ReturnPlayer(client).LAxeW then
								for i,v in pairs(client.Character:GetChildren()) do
									if v == client.Character:FindFirstChild("LightSaber Hatchet") then
										v:Destroy()
									end
								end
							end
						end
						repeat task.wait(.5)
							if (args[3].Position - client.Character.HumanoidRootPart.Position).Magnitude >= 28 and string.match(args[3].Name, client.Name) then
								args[3].Name = "EverGreen"
								PlayerStatManager:ReturnPlayer(client).DoneTreeGen = false;
								PlayerStatManager:ReturnPlayer(client).givenwoodfullGUI = false;
								for i,l in pairs(args[3]:GetChildren()) do
									if l.Name == "Behind of tree" or l.Name == "Right  of Tree" or l.Name == "Left  of Tree"  or l.Name == "Front  of Tree" then
										l:FindFirstChild("HealthBar").SurfaceGui.MainFrame.Storage.Text = ""
										l:FindFirstChild("HealthBar").SurfaceGui.Enabled = false;
										l:FindFirstChild("SurfaceGui").Enabled = false;
										l:FindFirstChild("HealthBar").SurfaceGui.Left.ImageColor3 = Color3.fromRGB(10, 248, 10)
									end
								end
								if args[3].Transparency > 0 then
									local TweenitBackUp = TweenService:Create(args[3], TweenInfo.new(2), {Transparency = 0})
									TweenitBackUp:Play()
									TweenitBackUp.Completed:wait();
								end
								PlayerStatManager:ReturnPlayer(client).GotLoop = false;
								if PlayerStatManager:GetStat(client, 'AutoChop') then
									remote:FireClient(client, 'Woodcutting', 'Reset Debouncers');
								end

								break;
							elseif (args[3].Position - client.Character.HumanoidRootPart.Position).Magnitude >= 28 and ((args[3].Name == "Diamond Tree") or (args[3].Name == "Golden Tree") or (args[3].Name == "Bronze Tree")) then
								if args[3].Transparency > 0 then
									for i,l in pairs(args[3]:GetChildren()) do
										if l.Name == "Behind of tree" or l.Name == "Right  of Tree" or l.Name == "Left  of Tree"  or l.Name == "Front  of Tree" then
											l:FindFirstChild("HealthBar").SurfaceGui.MainFrame.Storage.Text = ""
											l:FindFirstChild("HealthBar").SurfaceGui.Enabled = false;
											l:FindFirstChild("SurfaceGui").Enabled = false;
											l:FindFirstChild("HealthBar").SurfaceGui.Left.ImageColor3 = Color3.fromRGB(10, 248, 10)
										end
									end
									local TweenitBackUp = TweenService:Create(args[3], TweenInfo.new(2), {Transparency = 0})
									TweenitBackUp:Play()
									TweenitBackUp.Completed:wait();
								end
								PlayerStatManager:ReturnPlayer(client).GotLoop = false;
								if PlayerStatManager:GetStat(client, 'AutoChop') then
									remote:FireClient(client, 'Woodcutting', 'Reset Debouncers');
								end
								break;
							end
						until PlayerStatManager:ReturnPlayer(client).GotLoop == false;
					end

Hoping you could help me succeed this woodcutting script, I’ve been trying to fix this for ages and it’s very strange to me…

:grinning:

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

I am Currently Rewriting all the scripts, I feel like it’s not very Efficient so, a rewrite is needed since it was written in 2019 also

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.