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.
1 | local timelength = 20 |
2 |
3 | game.Players.PlayerAdded:connect( function (player) |
4 | sound:Play() |
5 | wait(timelength) |
6 | sound:Stop() |
7 | end ) |
Why isnt the script working and how can I fix it?
Do you have a variable assigned for "sound"? If you're just saying "sound" it has no idea what 'sound" is. Such as...
1 | sound = game.Workspace.sound |
Not exactly like that but you get the point.