I am trying to make a script that when a player joins it plays an audio for 20 seconds and stops. I have a sound object named "sound" with the id of the audio I want to play. Here is my script.
local timelength = 20
game.Players.PlayerAdded:connect(function(player)
sound:Play()
wait(timelength)
sound:Stop()
end)
Why isnt the script working and how can I fix it?

2 comments
I have also tried wait(20) and removed the 1st line and still didnt work.
Do you want all of the players to hear this sound or just the player who joined?