--wait(math.random(0,5)/10)

while true do
	game:GetService("RunService").Stepped:Wait()
	local target = workspace:FindFirstChild(script.Parent.TargetName.Value)--findNearestTorso(script.Parent:WaitForChild("HumanoidRootPart").Position)
	if target ~= nil and target:FindFirstChild("HumanoidRootPart") ~= nil then
		target = target:FindFirstChild("HumanoidRootPart")
		--script.Parent.Humanoid:MoveTo(target.Position, target)
		script.Parent.HumanoidRootPart.CFrame = CFrame.new(script.Parent.HumanoidRootPart.Position,target.Position)
		script.Parent.HumanoidRootPart.CFrame = script.Parent.HumanoidRootPart.CFrame + (script.Parent.HumanoidRootPart.CFrame.LookVector) / Vector3.new(3.5,3.5,3.5)
		if target ~= nil and (target.Position - script.Parent.HumanoidRootPart.Position).Magnitude < 0.5 then
			target.Parent.Humanoid.Health = 0
			script.Parent:Destroy()
			wait()
		end
	end
end
