I'm trying to create multiplayer game using BTC to make bets. I have server and I am using PHP to let users create an account. How would I write a script where when a new user creates an account the server also makes a new wallet for them where they can deposit, withdraw and use that wallet's balance to play games using BTC.
I'd advise caution, it is quite difficult to secure web wallets. What you are asking is pretty basic, when a new user registers you call your server (ie bitcoind) to create a new address, then assign that address to that userid in your database. Withdrawal would just be a call to send transaction. There's no script that will do this for you, it needs to be done from scratch.