Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I need help with a script that plays a sound in a specific way. Can someone help?

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)

3 comments

0

Use WaitForChild for every descendant of player. i.e. local sound = player:WaitForChild("PlayerGui"):WaitForChild("Sound") 

0

You should post that as an answer, it worked.

0

Sure.

3 answers

✓ Accepted answer

Use WaitForChild for every descendant of player. i.e.

local sound = player:WaitForChild("PlayerGui"):WaitForChild("Sound") 

1 comment

1

Thank you!

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)

1 comment

0

I forgot to mention, this is a music file with a low pitch. And that did not work, but thank you for the concern.

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)

3 comments

0

I forgot to mention again, the sound isn't playing at ALL. There is something wrong with my origional script and i cant figure out what.

0

@haxerlololol Show us your script?

0

I posted it in the question.

This discussion is preserved as it was. New answers, comments, and votes are closed.