Untitled

🧩 Syntax:
local boss = nil
local position = nil
local o = 0
function gettarget()
	wait()
	local target = nil
	local distance = math.huge
	local pos = game.Players.LocalPlayer.Character.HumanoidRootPart.Position+Vector3.new(math.random(-300,300),0,math.random(-300,300))
	if game.Players.LocalPlayer.Character:IsDescendantOf(game.Workspace) == true then
		for i,v in pairs(game.Workspace:GetDescendants()) do

			if v:IsA("ClickDetector") and v.Parent and game.Players:FindFirstChild(v.Parent.Name) == nil and (v.Parent.Position-pos).Magnitude < distance  then
				target = v.Parent
				distance =  (v.Parent.Position-pos).Magnitude
			end

		end
	end
	if target ~= nil then
		position = target.Position
		return target
	else
		return gettarget()
	end

end
function usetool()
	if game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Tool")~= nil then
		game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Tool"):Activate()
	else
		game.Players.LocalPlayer.Backpack:FindFirstChildWhichIsA("Tool").Parent = game.Players.LocalPlayer.Character
	end
end
function getstufffromnpc(npc)
	for i,v in pairs(npc:GetDescendants()) do
		if v:IsA("Humanoid") then
			return v.Parent:FindFirstChildWhichIsA("HumanoidRootPart")
		end
	end
	return nil
end
function loop2()
	game:GetService("RunService").Stepped:Wait()
	pcall(function()
	usetool()
	fireclickdetector(boss:FindFirstChildWhichIsA("ClickDetector"))
	end)
	loop2()
end
delay(0,function()
loop2()
end)
function tptonpc()
	game:GetService("RunService").Stepped:Wait()
	repeat wait() until boss ~= nil and game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character.Humanoid.Health >0 
	o+=1
	usetool()
	fireclickdetector(boss:FindFirstChildWhichIsA("ClickDetector"))
	if boss:IsA("Part") and boss:IsDescendantOf(game.Workspace) == true then
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = boss.CFrame
	else
		if getstufffromnpc(boss) ~= nil then
			game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame=getstufffromnpc(boss).CFrame
		end
	end
	if o>= math.random(500,999) then
		o = 0
		gettarget()
	end
	tptonpc()
end

for i,v in pairs(game.Workspace:GetDescendants()) do
	if v:IsA("ClickDetector")  then
		v:Destroy()
	end
end
function start()
	game:GetService("RunService").Stepped:Wait()
	boss = gettarget()
	if boss ~= nil then
		delay(0,function()
			repeat wait() until boss ==nil or boss:IsDescendantOf(game.Workspace) == false
			boss = nil
			start()
		end)
		tptonpc()
	else
		start()
	end
end
start()