Here’s the code i’ve tried, doesn’t seem to work
game.Players.PlayerRemoving:Connect(function(player)
local sound = game.SoundService:FindFirstChild("Bye")
if sound then
sound:Play()
end
end)
Here’s the code i’ve tried, doesn’t seem to work
game.Players.PlayerRemoving:Connect(function(player)
local sound = game.SoundService:FindFirstChild("Bye")
if sound then
sound:Play()
end
end)
Simply use a localscript and play the sound locally for the player. It should work, because it’s in a localscript.
Looking at previous posts on the DevForum, it seems that using PlayerRemoving on the client side is useless because the client scripts get deleted too quickly for the code within those scripts to run.
I’ve seen a previous person attempt to do this. Check when the local player is joining, which is so mind-bogglingly paradoxical, because the script itself runs when the player joins. It’s not like the script exists before the player joins.
im 90% sure you simply cannot stall the client from closing to play a sound sadly.
This won’t work because the script will terminate and get deleted quickly after the player leaves the game.
To make a sound play when a player leaves a game, you can use the PlayerRemoving
event in Roblox. This event is triggered when a player leaves the game, and it provides a player
object that represents the player that is leaving.
Here’s how you can use this event to play a sound when a player leaves the game.
game.Players.PlayerRemoving:Connect(function(player)
local sound = game.SoundService:FindFirstChild("Bye")
if sound then
sound:Play()
end
end)
Make sure that you have a sound asset named “Bye” in the SoundService
service, and that it is correctly referenced in the code above. If you are still having issues getting the sound to play, you may want to check the following:
Sound
object is properly parented to the SoundService
service.I hope this helps! Let me know if you have any questions
I’m not sure if that addresses OP’s question
How do you make a sound play locally when you leave a game?
Your method would work to tell other players that someone left, however it would not play for the person who disconnected.
(Also someone quoted me on a post I made almost a year ago xD)
To play a sound locally for the player who is leaving the game, you can use the LocalPlayer property of the Players service. This property returns the player object that represents the local player. Here is an example of how you can use the LocalPlayer property to play a sound for the player who is leaving the game.
game.Players.PlayerRemoving:Connect(function(player)
if player == game.Players.LocalPlayer then
local sound = game.SoundService:FindFirstChild("Bye")
if sound then
sound:Play()
end
end
end)
This will check if the player object that is being removed is the local player, and if it is, it will play the “Bye” sound. Make sure that you have a sound asset named “Bye” in the SoundService service and that it is correctly referenced in the code.
I hope this helps! Let me know if you have any other questions.
-- // Server
local PlayerService = game:GetService("Players")
local ByeSound: Sound = game:GetService("SoundService").Bye
PlayerService.PlayerRemoving:Connect(function(player: Player)
local SoundClone = ByeSound:Clone()
SoundClone.Parent = player
SoundClone:Play()
end)
Thanks!
I think you need to do:
game.Workspace.SoundService:FindFirstChild(“Bye”)
uhh… soundservice isnt in the workspace?
This post was clearly from 2 years ago.
Was SoundService in workspace 2 years ago? IDK
Its still available.
???
My SoundService is next to all the other tabs (ReplicatedStorage, StarterPlayer, etc)
cant take a screenshot now, im on a hotspot with internet speeds of 0.015MBPS (my mobile data ran out )
Bump. There’s a game on roblox called Habitat 84 that does this. I’ve asked the owner and all he said was “there’s posts on the devforum about it”. However, attempting to use the method given by @esadams188 does not work because, as abnerbro already stated:
I really can’t figure out how Habitat 84 did it.
I tried the solutions provided here but they still don’t work.