Jump to content

Need help with the Sound script.


Slim.

Recommended Posts

Well, I'm trying to make a script which plays a sound at the location specified.. but its not working. any errors?

local soundsTable = { 
"sound.mp3" 
} 
  
function Music() 
   local soundPath = soundsTable[math.random(#soundsTable)] 
   sound = playSound3D("sound/"..tostring(soundPath), -89.272094726563, -48.133323669434, 720.40222167969, true) 
   setSoundMaxDistance(sound,50) 
   setSoundVolume (sound,0.7) 
   outputChatBox(tostring(sound)) 
end 
setTimer(Music,50,1) 

and the meta..

  

   

Edited by Guest
Link to comment

there is no event on the script try this

  
local soundsTable = { 
  
"sound.mp3" 
} 
  
function Music() 
  
   local soundPath = soundsTable[math.random(#soundsTable)] 
  
   sound = playSound3D("sound/"..tostring(soundPath), -89.272094726563, -48.133323669434, 720.40222167969, true) 
  
    setSoundMaxDistance(sound,50) 
  
   setSoundVolume (sound,0.7) 
    
   outputChatBox(tostring(sound)) 
   setTimer(Music,50,1) 
end 
addEventHandler( "onClientResourceStart", getRootElement( ), Music) 
  
  

Link to comment

it is also supposed to show line numbers errors are at.

i am assuming this is not the whole script, cant see an obvious "attempt to call a userdata value"

oh and iirc if your mp3 is in a subfolder, you should specify it in meta.xml, right now you only have file name

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...