-
What do you want to achieve? Play a sound locally if player leaves the game.
-
What is the issue? Roblox closes too quickly.
-
What solutions have you tried so far? I have tried different approaches for the code such as ancestrychanged or even bindtoclose function which i found out can only be used on server unfortunately.
Hi, I would want to code a feature where if the player leaves the game it would play a sort of goodbye sound to him. The problem is that if player leaves the game, the roblox process ends too quickly for it to play the sound fully (around 100 milliseconds i believe). I noticed that one game has achieved it and I just can’t seem to figure out how. If you would like to visit it and check for yourself here’s the link: Habitat 84 - Roblox
After joining just leave the game and listen. While doing this i noticed in the task manager that roblox process takes longer to actually end so it might have to do something with that i presume.
local plr = game.Players.LocalPlayer
game.Players.PlayerRemoving:Connect(function(rmvplr)
if rmvplr == plr then
print("te")
local goodbyeSound = script:FindFirstChild("heiswatching"):Clone()
goodbyeSound.Parent = workspace
goodbyeSound:Play()
print("E")
wait(goodbyeSound.TimeLength)
print("st")
end
end)
In the code only “te” and “E” gets printed out.
Would be grateful for any help!