Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to play a song to only a specific player?

Asked by 6 years ago

I'm designing a congratulations GUI for when a player levels up. I want an audio to play but I only want the player that leveled up to hear the audio. How can I achieve this?

0
Just put the sound inside the player or their character Gey4Jesus69 2705 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

This is fairly easy to do. Simply parent the sound instance inside the player's PlayerGui and play it. The sound will be local.

game.Players.PlayerAdded:connect(function(player)
    local sound = Instance.new("Sound", player)
    sound.Name = "LocalSound"
    sound.SoundId = "rbxassetid://00000000"
end)
0
Thank you Michael_TheCreator 166 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

If it's only for a specific player, you put it where the client is. So, put it in PlayerGui or something in the 'Players' section and not in the Workspace as nearby players will hear. Putting it in PlayerGui will make the sound replicate only to the player.

local Player = game:GetService("Players").LocalPlayer
local Sound = Player.PlayerGui.ASound:Play()
0
What dragonmaster4111 did. liteImpulse 47 — 6y

Answer this question