Honansik

Dollhouse Roleplay Boombox Soundboard

Aug 4th, 2021
794
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local local_player = game.Players.LocalPlayer
  2. local soundboard_id = '7196595323'
  3. local soundboard_data = {
  4. [0.50]='bruh';
  5. [1.00]='bonk';
  6. [1.60]='oh he need some milk';
  7. [5.25]='dun dun dunnn';
  8. [9.17]='this is a certified hood classic';
  9. [12.20]='whoomp whoomp whoomp';
  10. [17.00]='mom get the camera';
  11. [20.80]='Run it back!!';
  12. [21.80]='Run it back!!';
  13. [24.00]='Run it back!!';
  14. [25.00]='Run it back!!';
  15. [27.70]='denied';
  16. }
  17. local ordered_list = {
  18.    
  19. }
  20. for i,v in pairs(soundboard_data) do
  21.     table.insert(ordered_list,i)
  22. end
  23. table.sort(ordered_list)
  24.  
  25. local function boom_box()
  26.    return local_player.Backpack:FindFirstChild("BoomBox") or (local_player.Character and local_player.Character:FindFirstChild("BoomBox"))
  27. end
  28.  
  29. local function set_boombox_id(boombox,id)
  30.    while not boombox.Handle:WaitForChild("Sound").SoundId:match(tostring(id)) do
  31.        wait()
  32.        boombox.Remote:FireServer("PlaySong",id)
  33.    end
  34.  
  35.   return
  36. end
  37. local function chat(msg)
  38.     game.ReplicatedStorage.DefaultChatSystemChatEvents.SayMessageRequest:FireServer(msg, "All")
  39. end
  40. local function set_boombox_pos(boombox,pos)
  41.    boombox.Handle.Sound.TimePosition = pos
  42. end
  43. local function play_sound(index)
  44.     local sound_pos = ordered_list[index]
  45.     if not boom_box() then return end
  46.     local bb = boom_box()
  47.     bb.Parent = local_player.Character
  48.     set_boombox_id(bb,soundboard_id)
  49.     set_boombox_pos(bb,sound_pos)
  50.     bb.Handle.Sound.Playing = true
  51.     chat(soundboard_data[sound_pos])
  52.     while bb.Handle.Sound.TimePosition < (ordered_list[index+1] or 0) do
  53.         game:GetService("RunService").RenderStepped:Wait()
  54.     end
  55.         bb.Handle.Sound.Playing = false
  56. end
  57. local ek = Enum.KeyCode
  58. local inputs = {
  59.     ek.KeypadOne,
  60.     ek.KeypadTwo,
  61.     ek.KeypadThree,
  62.     ek.KeypadFour,
  63.     ek.KeypadFive,
  64.     ek.KeypadSix,
  65.     ek.KeypadSeven,
  66.     ek.KeypadEight,
  67. }
  68.  
  69. local uis = game:GetService("UserInputService")
  70.  
  71. uis.InputBegan:Connect(function(input)
  72.     local finded = table.find(inputs,input.KeyCode)
  73.     if finded then
  74.        play_sound(finded)
  75.     end
  76. end)
RAW Paste Data