I need this script to play a sound for someone who just joined and only once. I have a sound with the ID set in the StarterGUI file.
local player = game.Players.PlayerAdded:connect(function(player) local sound = player.PlayerGui.Sound sound:Play() end)
Use WaitForChild for every descendant of player. i.e.
local sound = player:WaitForChild("PlayerGui"):WaitForChild("Sound")
just make is stop after 2 seconds
local player = game.Players.PlayerAdded:connect(function(player) local sound = player.PlayerGui.Sound sound:Play() wait(2) sound:Stop() end)
If you'd like to only play the sound once, simply turn the Looped property off!
game.Players.PlayerAdded:connect(function(player) local sound = player.PlayerGui.Sound sound.Looped = false sound:Play() end)