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?
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)
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()