The piecewise function is $$f(x)=\begin{cases} ax^3 & x\leq 2 \\ x^2+b, & x>2 \end{cases} $$
First I plug in the 2 into both functions and set them equal to each other $$ 2^2+b=a(2)^3$$ $$4+b=8a$$ $$\frac{1}{2}=a-b $$ Then I take the derivative of both functions and repeat $$3ax^2=2x+b$$ $$12a=4+b$$ $$a+b=\frac{1}{3} $$
I then subtract both equations from each others $$\frac{1}{2}=a-b $$ $$-\frac{1}{3}=a+b$$ to get $b=\frac{1}{6}$ and then $a=\frac{2}{3}$ but when I checked my answer I was wrong, I don't know where I went wrong
You are on the right track but you have made some algebra and derivative mistake in finding your $a$ and $b$.
Note that $$12a=4 \implies a=1/3$$
Also $$ 4+b=8a \implies a=1/2 +b/8$$
You can take it from here.