Place that in the OnTrigger method.
Also, split up the Instantiate code
var ball = Instantiate(ballPref, new Vector3(paddleObj.transform.position.x + 2, paddleObj.transform.position.y,0), Quaternion.identity) as GameObject;
ball.transform.parent = paddleObj;
That’ll at least makes it easier to use the ‘Debug.log()’ code to debug it. Debug both ‘Ball’ and ‘ball’ after instantiating them and see if either are null.
Well your second error message is just telling you that your Ball variable is not being used anymore after you destroy your ball. You could fix that by changing:
var ball = Instantiate(ballPref, new Vector3(paddleObj.transform.position.x + 2, paddleObj.transform.position.y,0), Quaternion.identity) as GameObject;
to just reuse the same variable:
Ball = Instantiate(ballPref, new Vector3(paddleObj.transform.position.x + 2, paddleObj.transform.position.y,0), Quaternion.identity);
Thanks idk what happened but somehow i managed to fix it. It’s now working properly with music and everything. Thanks a lot for your help guys!
been to a big help