I want to make a random sound player for a game but I can't figure it out, heres my code:
local sounds = {script.Parent.Sound, script.Parent.Sound2, script.Parent.Sound3} while true do wait(math.random(0.5, 5)) sounds(math.random):Play() end
This code doesn't work because of line 5
sounds(math.random):Play()
This would cause attempt to call a table value
error. What you want to do is index the table for a random sound.
local sounds = {script.Parent.Sound, script.Parent.Sound2, script.Parent.Sound3} while true do wait(math.random(1, 5)) local sound = sounds[math.random(#sounds)] sound:Play() end
sound
variable