Supr14
|
  |
| Joined: 08 Nov 2015 |
| Total Posts: 1817 |
|
|
| 30 Oct 2017 04:57 PM |
So i got a table with multiple id's, when i execute it, it plays a random id, however, if i press the key "T", then it plays the exact same id it played when it executed. How do i make it so that it plays random each time i hit the "T" key? Here is the script for ya: local soundtable = {907329532,907330011,907330103,907328384,907328262,907328908,907328689} local rdnm = soundtable[math.random(1,hashtagsoundtable)] tauntsound = Instance.new("Sound", Head) tauntsound.Volume = 2 tauntsound.SoundId = soundid ..rdnm tauntsound.Looped = false tauntsound:Play() mouse.KeyDown:connect(function(Press) Press=Press:lower() if Press=='t' and walking == false then if tauntdebounce == true then return end tauntdebounce = true tauntsound:Play() wait(1) tauntdebounce = false end end) |
|
|
| Report Abuse |
|
|
| 30 Oct 2017 05:00 PM |
1. You made this post already
2. KeyDown is deprecated in favour of UserInputService.InputBegan
3. The reason it plays the same sound is because you choose the random id at the beginning of the script, pressing the 't' key will make it play the same sound over again. Instead, choose the random sound in the function connected to KeyDown. |
|
|
| Report Abuse |
|
|
| 30 Oct 2017 05:01 PM |
mouse.KeyDown:connect(function(Press) Press = Press:lower() if Press == "t" and tauntdebounce and walking == false then tauntdebounce = true local randSong = soundtable[math.random(1,#soundtable)] tauntsound:Stop() tauntsound.SoundId = randSong sauntsound:Play() wait(1) tauntdebounce = false end end)
|
|
|
| Report Abuse |
|