So, in pressure, when you leave, it’s going to play a sound locally with the message ‘Good luck out there!’ Also, previously, when you left pls donate, it would play a fart sound… But can anyone help me out?
hmmm, and I think with playonremove
No, the PlayOnRemove property on audio assets decides wether it will continue playing when :Destroy() is called on the audio. It has nothing to do with playing on the player’s removal.
Referring to what @Scottifly said, you can use the PlayerRemoving event to play a sound when the player leaves.
Here’s an example for a localscript:
local sound = -- Paste the ID of the sound you want to play here
local players = game:GetService("Players")
local function playOnLeave(player)
sound:Play()
end
players.PlayerRemoving:Connect(playOnLeave)
Do you need the sound to play for the player that’s leaving, or for the rest of the players in the game?
@AlexPalex178, if they need it to play for the player would they need a custom leaving script to delay the player until the sound is heard?
I’m not sure. For me, it’s always 1-2 seconds after pressing the leave button until I actually get to the homepage.
That time should suffice to play a short-length sound.
I don’t know if this goes for everybody, as the laptop I’m using is pretty old and slow, and so are loading times.
Look at pressure horror game, when you leave from lobby
I haven’t played the game. If you want make a short video.
So are you talking about when a player quits a game or when they are teleported to another place from a lobby?
If it’s the teleport then just play the sound in the teleport script. Do it with enough of a delay so they’ll hear the sound, then get teleported.
when player quits the game using leave button
Found out how to do it, not gonna share it cuz people might do bad stuff with it…
Would appreciate if you could at least share privately, I’ve been attempting something similar to this (where a goodbye audio is played when the player is leaving the game) and have failed multiple times and im completely frozen in progress now. Thanks!
Ok, here’s my method then.
I can’t test this right now, but if it doesn’t work it should be a good basis.
--LocalScript / RuntimeContext Client
local Player = game.Players.LocalPlayer
local Sound = path.to.sound
Player.Destroying:Connect(function()
Sound:Play()
end)
Appears as though I’ve replied to the wrong person, here is the method @SnepQueen
But doesn’t that still play the sound after the player leaves?
Ok guys for those who will dig down this post:
local sound = script.Sound
game.OnClose = function()
sound:Play()
task.wait(sound.TimeLength)
end
Just did a little searching and found BindToClose which can be used to delay the shutdown for a period of time. Check the second sample script.
I’m not sure if the player is still in the game while this is working though.
It only works in real roblox runtime
- use screenGUI and put the script inside of it and disable the reset on spawn.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.