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 8 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.

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

3 answers

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

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

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

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)

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 — 8y
Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
8 years ago

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)
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 — 8y
0
@haxerlololol Show us your script? Shawnyg 4330 — 8y
0
I posted it in the question. Galvarino 25 — 8y

Answer this question