Shady1 Posted June 27, 2021 Share Posted June 27, 2021 I installed music on login panel and it works, but when I log in, the music still continues, how can I stop it? Link to comment
SpecT Posted June 27, 2021 Share Posted June 27, 2021 Hey, Here is an example: local sound function login() sound = playSound(...) end function afterLogin() if isElement(sound) then stopSound(sound) end end Link to comment
Shady1 Posted June 27, 2021 Author Share Posted June 27, 2021 addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() setTimer(function() --playSound("winsound.mp3") end, 2000, 1) end ) How can I integrate the codes you wrote into them exactly? can you help me because i tried i couldn't. brruggghh Link to comment
SpecT Posted June 27, 2021 Share Posted June 27, 2021 Well it's similar to the example I gave you. local sound addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() setTimer(function() sound = playSound("winsound.mp3") end, 2000, 1) end ) -- And in the function where the player logs in successfully put this: if isElement(sound) then stopSound(sound) end Link to comment
Shady1 Posted June 27, 2021 Author Share Posted June 27, 2021 thank you but when i log in the music still continues, can you help me if i give you client and server Link to comment
βurak Posted June 27, 2021 Share Posted June 27, 2021 (edited) You can solve this problem by creating an event on client side and running it with triggerClientEvent on server side client: local sound addEventHandler("onClientResourceStart", resourceRoot, function() setTimer(function() sound = playSound("winsound.mp3") end, 2000, 1) end ) addEvent("stopLoginMusic", true) addEventHandler("stopLoginMusic", root, function() if isElement(sound) then stopSound(sound) end end ) server: addEventHandler("onPlayerLogin", root, function() triggerClientEvent(source, "stopLoginMusic", source) end ) Edited June 27, 2021 by Burak5312 1 Link to comment
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