Desaster Posted October 14, 2013 Posted October 14, 2013 I cant find the problem addEventHandler("onPlayerLogin", root, function() JoinMusic = playSound("music/join.mp3") end) ERROR : attemp to call global playSound ( a nil value )
pa3ck Posted October 14, 2013 Posted October 14, 2013 (edited) 'onPlayerLogin' is server side and playSound is client side Use the triggerClientEvent from server side to client side. Edited October 14, 2013 by Guest
mint3d Posted October 14, 2013 Posted October 14, 2013 --client side -- JoinMusic = playSound("music/join.mp3") addEvent("onPlayerLogin", true) addEventHandler("onClientPlayerSpawn", root, function() if isElement(JoinMusic) then destroyElement(JoinMusic) end end) -- Server Side -- addEventHandler("onPlayerLogin", root, function() triggerClientEvent(source, "onClientPlayerSpawn", source) end)
Desaster Posted October 14, 2013 Author Posted October 14, 2013 thnx for fast answer I got it now I named the file client and it is a server file so i thought it was client thnx for fast answer
Castillo Posted October 14, 2013 Posted October 14, 2013 --client side -- JoinMusic = playSound("music/join.mp3") addEvent("onPlayerLogin", true) addEventHandler("onClientPlayerSpawn", root, function() if isElement(JoinMusic) then destroyElement(JoinMusic) end end) -- Server Side -- addEventHandler("onPlayerLogin", root, function() triggerClientEvent(source, "onClientPlayerSpawn", source) end) You have a problem in the client side, you put "onPlayerLogin" on addEvent, and "onClientPlayerSpawn" on addEventHandler.
Desaster Posted October 14, 2013 Author Posted October 14, 2013 client : addEvent("onPlayerPlayMusic", true) addEventHandler("onPlayerPlayMusic", root, function() JoinMusic = playSound("music/join.mp3") end) server : addEventHandler("onPlayerLogin", root, function() triggerClientEvent(source, "onPlayerPlayMusic", source) end)
Castillo Posted October 14, 2013 Posted October 14, 2013 It works fine tho? That's because you are using a event which already exists, so, it must be playing the sound when the player spawns.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now