k here is the code i have:
rem HIDE THE MOUSE AND LIMIT THE SYNC RATE TO 40
hide mouse:sync rate 40
rem MAKE THE PADDLES, BALL AND FLOOR
make object box 1,1,1,5:color object 1,rgb(255,0,0)
make object box 2,1,1,5:color object 2,rgb(0,255,0)
make object sphere 3,1:color object 3,rgb(0,0,50)
make object box 4,50,0.1,50:position object 4,0,-0.55,0
rem Load sounds
WorldSnd=1 : load sound "sounds\NG12922.wav", WorldSnd
HitSnd=2 : load sound "sounds\pong.wav", HitSnd
loop sound WorldSnd : set sound volume WorldSnd,50
rem SET THE BALL ANGLE TO 90 DEGREES
balla#=90
rem START THE MAIN LOOP
sync on:do
rem SCORING
if ballx#>30 then player2score#=player2score#+1:ballx#=0:ballz#=0:balla#=270
if ballx#<-30 then player1score#=player1score#+1:ballx#=0:ballz#=0:balla#=90
set cursor 300,50:print player2score#
set cursor 320,50:print "-"
set cursor 340,50:print player1score#
rem BALL MOVEMENT
ballx#=newxvalue(ballx#,balla#,0.6):ballz#=newzvalue(ballz#,balla#,0.6)
rem PLAYER 1 PADDLE MOVEMENT
IF upkey()=1 and player1pos#<23 then player1pos#=player1pos#+0.5
IF downkey()=1 and player1pos#>-23 then player1pos#=player1pos#-0.5
if upkey()=1 and ballx#>4 and ballx#<4.5 then balla#=balla#+8
if downkey()=1 and ballx#>4 and ballx#<4.5 then balla#=balla#-8
rem PLAYER 2 PADDLE MOVEMENT
IF keystate(17)=1 and player2pos#<23 then player2pos#=player2pos#+0.5
IF keystate(31)=1 and player2pos#>-23 then player2pos#=player2pos#-0.5
if keystate(17)=1 and ballx#<-4 and ballx#>-4.5 then balla#=balla#+8
if keystate(31)=1 and ballx#<-4 and ballx#>-4.5 then balla#=balla#-8
rem BOUNCING
if ballx#>22 and ballx#<23 and ABS(player1pos#-ballz#)<2.5 then balla#=360-balla#
if ballx#<-22 and ballx#>-23 and ABS(player2pos#-ballz#)<2.5 then balla#=360-balla#
if ballz#>24 or ballz#<-23 then balla#=180-balla#
IF OBJECT collision(1,3)=1 then play sound HitSnd : set sound volume HitSnd,100
IF OBJECT collision(2,3)=1 then play sound HitSnd : set sound volume HitSnd,100
rem MAKE SURE balla# IS LESS THAN 360 AND MORE THAN 0
balla#=wrapvalue(balla#)
rem POSITION OBJECTS
position object 1,24,0,player1pos#:position object 2,-24,0,player2pos#
position object 3,ballx#,0,ballz#:yrotate object 3,balla#
position camera 0,50,-10:point camera 0,0,0
sync:loop
As you can see i tried an if statement for the play sound.
Also tried
if (collision statement) then Hit#=1
if Hit#=1 then play sound
but had same results.