How do i Set math.random to set Current_Taunt to a Random Value inside the TauntsID Table?
TauntsID = {138093241,130779878, 15331714, 139455448, 132179181, 140649307} for _, asset in ipairs(TauntsID) do Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset) end Sounds.TauntS.Parent = Client_Char.Head TauntS = Client_Char.Head.TauntS Client_Mouse.KeyDown:connect(function(TKey_Val) if (TKey_Val == "g") and not (TauntDeb) then Current_Taunt = math.random(1,#TauntsID) TauntS.SoundId = "http://www.roblox.com/asset/?id="..Current_Taunt wait(1) TauntDeb = true TauntS:play() wait(15) TauntDeb = false end end)
In a table, you can take the table's name followed by brackets and a number, and that gives you the value corresponding to the number, like this:
MyTable = {"Hi","People","I'm","Perci1!"} print(MyTable[1]) print(MyTable[3]) --output: Hi, I'm
Therefore we can get a random value by getting a random number.
MyTable = {"Hi","People","I'm","Perci1!"} randomNumber = math.random[1,#MyTable] --#MyTable is the amount of values in the table. In this situation, 4. randomValue = MyTable[randomNumber] print[randomValue]
This is one way of doing it, but it would be easier to do it all in 1 step.
MyTable = {"Hi","People","I'm","Perci1!"} print(MyTable[math.random(1,#MyTable)])
The same method applies to your script.
local Current_Taunt=TauntsID[math.random(1,#TauntsID)]
Set it to a random index value of the table:
Current_Taunt = TauntsID[math.random(#TauntsUD)]