sound system test

Run Settings
LanguageLua
Language Version
Run Command
local random = Random.new() local soundTable = { ["Bass"] = {}; ["Ping"] = {}; ["Snap"] = {} } local currentBass = 1 local currentPing = 1 local currentSnap = 1 for i = 1, 3 do for s = 1, 6 do local sEffect = Instance.new("Sound") sEffect.Volume = 1.4 sEffect.Parent = owner.Character.Torso if i == 1 then sEffect.SoundId = "rbxasset://sounds/bass.mp3" table.insert(soundTable["Bass"], sEffect) elseif i == 2 then sEffect.SoundId = "rbxasset://sounds/electronicpingshort.wav" table.insert(soundTable["Ping"], sEffect) elseif i == 3 then sEffect.SoundId = "rbxasset://sounds/snap.mp3" table.insert(soundTable["Snap"], sEffect) end end end function playSound(s, p) if s == "bass" then currentBass += 1 if currentBass > #soundTable["Bass"] then currentBass = 1 end local sound = soundTable["Bass"][currentBass] sound.TimePosition = 0.12 sound.Pitch = p sound.Playing = true return sound elseif s == "ping" then currentPing += 1 if currentPing > #soundTable["Ping"] then currentPing = 1 end local sound = soundTable["Ping"][currentPing] sound.TimePosition = 0.2 sound.Pitch = p sound.Playing = true return sound elseif s == "snap" then currentSnap += 1 if currentSnap > #soundTable["Snap"] then currentSnap = 1 end local sound = soundTable["Snap"][currentSnap] sound.TimePosition = 0.2 sound.Pitch = p sound.Playing = true return sound end end local sounds = { ["IdleSong"] = { ["Tempo"] = 120, ["Patterns"] = { [1] = { [1] = {"note", 3.6}, [2] = {"note", 1.8, 7}, [3] = {"note", 2.64}, [4] = {"note", 3.6}, [5] = {"note", 4.2}, [6] = {"note", 4.8}, [7] = {"note", 1.8, 1}, [8] = {"note", 4.24}, [9] = {"note", 2.8}, [10] = {"note", 1.4, 7}, [11] = {"note", 2.64}, [12] = {"note", 3.6}, [13] = {"note", 4.2}, [14] = {"note", 4.8}, [15] = {"note", 1.4, 1}, [16] = {"note", 4.24}, [17] = {"note", 2.4}, [18] = {"note", 1.2, 7}, [19] = {"note", 2.64}, [20] = {"note", 3.6}, [21] = {"note", 4.2}, [22] = {"note", 4.8}, [23] = {"note", 1.2, 1}, [24] = {"note", 4.24}, [25] = {"note", 2.64}, [26] = {"note", 1.32, 7}, [27] = {"note", 2.64}, [28] = {"note", 3.6}, [29] = {"note", 4.2}, [30] = {"note", 4.8}, [31] = {"note", 1.32, 1}, [32] = {"note", 4.24}, [33] = {"repeat", 1} }, [2] = { [1] = {"note", 0.9}, [2] = {"note", 1.8}, [3] = {"note", 1.6}, [4] = {"note", 1.4}, [5] = {"note", 1.6}, [6] = {"note", 1.4}, [7] = {"note", 1.325}, [8] = {"note", 1.4}, [9] = {"note", 1.325}, [10] = {"note", 1.2}, [11] = {"note", 1.325}, [12] = {"note", 1.2}, [13] = {"note", 1.325}, [14] = {"note", 1.4}, [15] = {"note", 1.325}, [16] = {"note", 1.2}, [17] = {"note", 0.7}, [18] = {"note", 0.788}, [19] = {"note", 0.9}, [20] = {"note", 0.788}, [21] = {"note", 0.9}, [22] = {"note", 1}, [23] = {"note", 0.9}, [24] = {"note", 1}, [25] = {"note", 1.09}, [26] = {"note", 1}, [27] = {"note", 1.09}, [28] = {"note", 1.2}, [29] = {"note", 1.09}, [30] = {"note", 1.2}, [31] = {"note", 1.325}, [32] = {"note", 1.425}, [33] = {"note", 0.6}, [34] = {"note", 1.2}, [35] = {"note", 1.075}, [36] = {"note", 0.933}, [37] = {"note", 1.075}, [38] = {"note", 0.933}, [39] = {"note", 0.883}, [40] = {"note", 0.933}, [41] = {"note", 0.883}, [42] = {"note", 0.8}, [43] = {"note", 0.883}, [44] = {"note", 0.8}, [45] = {"note", 0.883}, [46] = {"note", 0.933}, [47] = {"note", 0.883}, [48] = {"note", 0.8}, [49] = {"note", 0.675}, [50] = {"note", 0.75}, [51] = {"note", 0.85}, [52] = {"note", 0.75}, [53] = {"note", 0.85}, [54] = {"note", 0.9}, [55] = {"note", 0.85}, [56] = {"note", 0.9}, [57] = {"note", 1}, [58] = {"note", 0.9}, [59] = {"note", 1}, [60] = {"note", 1.05}, [61] = {"note", 1}, [62] = {"note", 1.05}, [63] = {"note", 1.18}, [64] = {"note", 1.35}, [65] = {"repeat", 1} } } }; ["EHAHA"] = function() task.spawn(function() for i = 1, 6 do local sound = playSound("bass", 3 + i * 0.175) task.wait(0.03) sound.Playing = false end for e = 1, 9 do for i = 1, 4 do local sound = playSound("bass", 4 - (e * 0.2) + (i * 0.4)) task.wait(0.03) sound.Playing = false end end end) end; ["DeathSound"] = function() task.spawn(function() for i = 1, 17 do local sound = playSound("ping", 1.55 + i * 0.05) if i % 2 == 0 then sound = playSound("ping", (sound.Pitch - 0.05) / 2) end task.wait(0.06) end for i = 1, 20 do local sound = playSound("snap", i * 0.1) task.wait(0.02) end for i = 1, 20 do local sound = playSound("snap", 2.1 - i * 0.1) task.wait(0.02) end end) end; ["HitSound"] = function() task.spawn(function() local c = random:NextInteger(1, 3) if c == 1 then for i = 1, 10 do playSound("snap", 1.5 - i * 0.1) task.wait(0.04) end elseif c == 2 then playSound("snap", 0.6) task.wait(0.08) playSound("snap", 1.2) task.wait(0.08) elseif c == 3 then for i = 1, 5 do playSound("snap", i * 0.25) task.wait(0.04) end end end) end; ["BANG"] = function() task.spawn(function() local rPitch = random:NextNumber(1, 1.4) for i = 1, 2 do playSound("snap", 0.8 * rPitch) task.wait(0.04) end for i = 1, 10 do playSound("snap", 0.325 * rPitch - i * 0.02) task.wait(0.04) end end) end; ["ZAP"] = function() task.spawn(function() for i = 1, 6 do playSound("bass", 2.3 * random:NextInteger(1, 2)) task.wait(0.04) end for i = 1, 6 do playSound("bass", 1.15 * random:NextInteger(1, 2)) task.wait(0.04) end end) end; ["Shatter"] = function() task.spawn(function() for i = 1, 20 do playSound("ping", random:NextNumber(1.6, 4.2)) playSound("snap", random:NextNumber(1.5, 2.5)) task.wait(random:NextNumber(0.01, i / 100)) end end) end; ["Kaboom"] = function() task.spawn(function() local c = random:NextInteger(1, 3) if c == 1 then for i = 1, 30 do playSound("snap", 0.6 - i * 0.015) task.wait(0.06) end elseif c == 2 then for i = 1, 20 do playSound("snap", (2 / i) + 0.2) task.wait(0.02) end elseif c == 3 then for i = 1, 3 do playSound("snap", 3.4) task.wait(0.03) end for i = 1, 20 do playSound("snap", 1.4 - i * 0.06) task.wait(0.03) end end end) end; ["FallSound"] = function() task.spawn(function() for i = 1, 30 do playSound("ping", 4 - i * 0.06) task.wait(0.06) end end) end; ["LaunchSound"] = function() task.spawn(function() for i = 1, 20 do playSound("snap", i * 0.1) task.wait(0.02) end for i = 1, 20 do playSound("bass", 10 - i * 0.26) playSound("snap", 2.1 - i * 0.1) task.wait(0.02) end end) end; ["Dong"] = function() task.spawn(function() playSound("bass", 9.2) playSound("ping", 2.64) playSound("snap", 2) task.wait(0.06) for i = 1,4 do playSound("bass", 12.6) playSound("ping", 3.6) task.wait(0.06) end end) end; ["ShootSound"] = function() task.spawn(function() for i = 1, 7 do local bass = playSound("bass", 10 - i * 0.8) local snap = playSound("snap", 0) if i < 3 then snap.Pitch = 2 end task.wait(0.02) bass.Playing = false snap.Playing = false end end) end; ["OW"] = function() task.spawn(function() for i = 1, 3 do local bass = playSound("bass", 9 + i * 0.3) task.wait(0.04) bass.Playing = false end for i = 1, 4 do local bass = playSound("bass", 9.75 - i * 0.6) task.wait(0.04) bass.Playing = false end end) end; ["AOW"] = function() task.spawn(function() for i = 1, 40 do local pit = 2.5 + (i + 38) * 0.15 if i > 8 then pit = 9 - (i - 4) * 0.15 end local bass = playSound("bass", pit) task.wait(0.04) bass.Playing = false end end) end; ["Collide"] = function() task.spawn(function() local c = math.random(1,2) if c == 1 then for i = 1, 3 do local snap = playSound("snap", 1) task.wait(0.04) snap.Playing = false end elseif c == 2 then for i = 1, 2 do local snap = playSound("snap", 0.9) task.wait(0.04) snap.Playing = false task.wait(0.04) end end end) end; ["RecoverSound"] = function() task.spawn(function() for i = 1, 15 do local ping = playSound("ping", i * 0.3) task.wait(0.06) ping.Playing = false end end) end; ["SwingSound"] = function() task.spawn(function() for i = 1, 5 do local snap = playSound("snap", 1 + i * 0.1) task.wait(0.04) snap.Playing = false end end) end; ["Swoosh"] = function() task.spawn(function() local rPitch = random:NextNumber(0.8, 1.4) for i = 1, 5 do local snap = playSound("snap", 0.5 * rPitch + i * 0.12) task.wait(0.04) snap.Playing = false end for i = 1, 5 do local snap = playSound("snap", 1.1 * rPitch - i * 0.12) task.wait(0.04) snap.Playing = false end end) end; ["Ding"] = function() task.spawn(function() playSound("bass", 12.5) playSound("bass", 3.6) task.wait(0.06) for i = 1, 4 do playSound("bass", 19) playSound("ping", 5.3) task.wait(0.06) end end) end; ["Healboom"] = function() task.spawn(function() for i = 1, 30 do playSound("snap", 0.3 + i * 0.03) task.wait(0.06) end end) end; ["AHAHA"] = function() task.spawn(function() for i = 1, 6 do local bass = playSound("bass", 4 + i * 0.3) task.wait(0.03) bass.Playing = false end for e = 1, 9 do for i = 1, 4 do local bass = playSound("bass", 6 - e * 0.4 + i * 0.6) task.wait(0.03) bass.Playing = false end end end) end; ["YAH"] = function() task.spawn(function() for i = 1, 3 do local bass = playSound("bass", i * 3) task.wait(0.03) bass.Playing = false end for i = 1, 2 do local bass = playSound("bass", 9) task.wait(0.03) bass.Playing = false end for i = 1, 8 do local bass = playSound("bass", 6 - i * 0.3) task.wait(0.04) bass.Playing = false end end) end; ["YO"] = function() task.spawn(function() for i = 1, 3 do local bass = playSound("bass", i * 2) task.wait(0.03) bass.Playing = false end for i = 1, 2 do local bass = playSound("bass", 6) task.wait(0.03) bass.Playing = false end for i = 1, 5 do local bass = playSound("bass", 4 - i * 0.3) task.wait(0.04) bass.Playing = false end end) end; ["HealField"] = function() task.spawn(function() for i = 1, 3 do playSound("snap", 0.5) task.wait(0.02) end for i = 1, 9 do local bass = playSound("bass", -0.12 * (i - 6) ^ 2 + 9) task.wait(0.04) bass.Playing = false end for i = 1, 3 do playSound("snap", 0.8) task.wait(0.02) end for i = 1, 14 do local bass = playSound("bass", -0.03 * (i - 4) ^ 2 + 7.5) task.wait(0.04) bass.Playing = false end end) end } local remote = Instance.new("RemoteEvent") remote.Name = "soundRemote" remote.Parent = owner.PlayerGui NLS([[local remote = script.Parent:FindFirstChild("soundRemote") local UIS = game:GetService("UserInputService") UIS.InputBegan:connect(function(key, g) if not g then remote:FireServer(key.KeyCode, "keydown") end end) UIS.InputEnded:connect(function(key, g) if not g then remote:FireServer(key.KeyCode, "keyup") end end) ]], owner.PlayerGui) remote.OnServerEvent:Connect(function(plr, key, input) if input == "keydown" then if key == Enum.KeyCode.Q then task.spawn(function() local currentPattern = 1 local currentNote = 0 local repeatCounter = 0 local noteRepeatCounter = 0 local iSTempo = 60 / sounds["IdleSong"]["Tempo"] local idleSong = sounds["IdleSong"]["Patterns"] while true do if currentNote > 0 then if idleSong[currentPattern][currentNote][3] == nil then currentNote += 1 else if noteRepeatCounter < idleSong[currentPattern][currentNote][3] then noteRepeatCounter += 1 else currentNote += 1 noteRepeatCounter = 0 end end else currentNote = 1 end if idleSong[currentPattern][currentNote][1] == "repeat" then if repeatCounter < idleSong[currentPattern][currentNote][2] then currentNote = 1 repeatCounter += 1 else currentPattern += 1 if currentPattern > #idleSong then break end currentNote = 1 repeatCounter = 0 end end local bass = playSound("bass", 0) local bass2 if currentPattern == 2 then if currentBass ~= 1 then bass2 = soundTable["Bass"][currentBass - 1] elseif currentBass == 6 then bass2 = soundTable["Bass"][currentBass - 1] else bass2 = soundTable["Bass"][currentBass + 1] end bass2.Playing = true bass2.Parent = owner.Character.Torso bass2.Pitch = idleSong[currentPattern][currentNote][2] * 2 bass2.TimePosition = 0.12 end bass.Pitch = idleSong[currentPattern][currentNote][2] bass.TimePosition = 0.12 task.wait(iSTempo / 4) bass.Playing = false end end) elseif key == Enum.KeyCode.E then sounds["EHAHA"]() elseif key == Enum.KeyCode.R then sounds["DeathSound"]() elseif key == Enum.KeyCode.T then sounds["HitSound"]() elseif key == Enum.KeyCode.Y then sounds["BANG"]() elseif key == Enum.KeyCode.U then sounds["ZAP"]() elseif key == Enum.KeyCode.P then sounds["Shatter"]() elseif key == Enum.KeyCode.F then sounds["Kaboom"]() elseif key == Enum.KeyCode.G then sounds["FallSound"]() elseif key == Enum.KeyCode.H then sounds["LaunchSound"]() elseif key == Enum.KeyCode.J then sounds["Dong"]() elseif key == Enum.KeyCode.K then sounds["ShootSound"]() elseif key == Enum.KeyCode.L then sounds["OW"]() elseif key == Enum.KeyCode.Z then sounds["AOW"]() elseif key == Enum.KeyCode.X then sounds["Collide"]() elseif key == Enum.KeyCode.C then sounds["RecoverSound"]() elseif key == Enum.KeyCode.V then sounds["SwingSound"]() elseif key == Enum.KeyCode.B then sounds["Swoosh"]() elseif key == Enum.KeyCode.N then sounds["Ding"]() elseif key == Enum.KeyCode.M then sounds["Healboom"]() elseif key == Enum.KeyCode.Comma then sounds["AHAHA"]() elseif key == Enum.KeyCode.Semicolon then sounds["YAH"]() elseif key == Enum.KeyCode.LeftBracket then sounds["YO"]() elseif key == Enum.KeyCode.RightBracket then sounds["HealField"]() end end end)
Editor Settings
Theme
Key bindings
Full width
Lines