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

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

Asked by 9 years ago

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.

1local player = game.Players.PlayerAdded:connect(function(player)
2local sound = player.PlayerGui.Sound
3sound:Play()
4end)
0
Use WaitForChild for every descendant of player. i.e. local sound = player:WaitForChild("PlayerGui"):WaitForChild("Sound")  XAXA 1569 — 9y
0
You should post that as an answer, it worked. Galvarino 25 — 9y
0
Sure. XAXA 1569 — 9y

3 answers

Log in to vote
0
Answered by
XAXA 1569 Moderation Voter
9 years ago

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

1local sound = player:WaitForChild("PlayerGui"):WaitForChild("Sound")
1
Thank you! Galvarino 25 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

just make is stop after 2 seconds

1local player = game.Players.PlayerAdded:connect(function(player)
2local sound = player.PlayerGui.Sound
3sound:Play()
4wait(2)
5sound:Stop()
6end)
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. Galvarino 25 — 9y
Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

If you'd like to only play the sound once, simply turn the Looped property off!

1game.Players.PlayerAdded:connect(function(player)
2    local sound = player.PlayerGui.Sound
3    sound.Looped = false
4    sound:Play()
5end)
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. Galvarino 25 — 9y
0
@haxerlololol Show us your script? Shawnyg 4330 — 9y
0
I posted it in the question. Galvarino 25 — 9y

Answer this question