generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Changing music each time in a table

Previous Thread :: Next Thread 
Supr14 is not online. 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
chexyalani is online. chexyalani
Joined: 26 Mar 2017
Total Posts: 694
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
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image