KrYn0MoRe

bluetooth speaker

May 12th, 2020
731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.20 KB | None | 0 0
  1. Tool0 = Instance.new("Tool")
  2. Part1 = Instance.new("Part")
  3. Part2 = Instance.new("Part")
  4. Part3 = Instance.new("Part")
  5. Part4 = Instance.new("Part")
  6. Part5 = Instance.new("Part")
  7. Tool0.Name = "KrY's BlueTooth Speaker"
  8. Tool0.Parent = owner['Backpack']
  9. Part1.Parent = Tool0
  10. Part1.CFrame = CFrame.new(-8.68000126, 4.25000429, -14.0999937, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  11. Part1.Orientation = Vector3.new(0, 180, 0)
  12. Part1.Position = Vector3.new(-8.68000126, 4.25000429, -14.0999937)
  13. Part1.Rotation = Vector3.new(-180, 0, -180)
  14. Part1.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  15. Part1.Size = Vector3.new(0.0700000077, 0.699999988, 0.699999988)
  16. Part1.BottomSurface = Enum.SurfaceType.Smooth
  17. Part1.BrickColor = BrickColor.new("Really black")
  18. Part1.Locked = true
  19. Part1.Material = Enum.Material.SmoothPlastic
  20. Part1.TopSurface = Enum.SurfaceType.Smooth
  21. Part1.brickColor = BrickColor.new("Really black")
  22. Part2.Parent = Tool0
  23. Part2.CFrame = CFrame.new(-7.42000055, 4.25000429, -14.0999937, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  24. Part2.Position = Vector3.new(-7.42000055, 4.25000429, -14.0999937)
  25. Part2.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  26. Part2.Size = Vector3.new(0.0700000077, 0.699999988, 0.699999988)
  27. Part2.BottomSurface = Enum.SurfaceType.Smooth
  28. Part2.BrickColor = BrickColor.new("Really black")
  29. Part2.Locked = true
  30. Part2.Material = Enum.Material.SmoothPlastic
  31. Part2.TopSurface = Enum.SurfaceType.Smooth
  32. Part2.brickColor = BrickColor.new("Really black")
  33. Part3.Name = "Handle"
  34. Part3.Parent = Tool0
  35. Part3.CFrame = CFrame.new(-8.0500021, 4.25000429, -14.0999937, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  36. Part3.Position = Vector3.new(-8.0500021, 4.25000429, -14.0999937)
  37. Part3.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  38. Part3.Size = Vector3.new(1.05000019, 0.699999988, 0.699999988)
  39. Part3.BottomSurface = Enum.SurfaceType.Smooth
  40. Part3.BrickColor = BrickColor.new("Really black")
  41. Part3.Locked = true
  42. Part3.Material = Enum.Material.SmoothPlastic
  43. Part3.TopSurface = Enum.SurfaceType.Smooth
  44. Part3.brickColor = BrickColor.new("Really black")
  45. Part4.Name = "led"
  46. Part4.Parent = Tool0
  47. Part4.CFrame = CFrame.new(-7.48999977, 4.25000429, -14.0999937, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  48. Part4.Position = Vector3.new(-7.48999977, 4.25000429, -14.0999937)
  49. Part4.Color = Color3.new(0.972549, 0.972549, 0.972549)
  50. Part4.Size = Vector3.new(0.0700000077, 0.699999988, 0.699999988)
  51. Part4.BottomSurface = Enum.SurfaceType.Smooth
  52. Part4.BrickColor = BrickColor.new("Institutional white")
  53. Part4.Locked = true
  54. Part4.Material = Enum.Material.Neon
  55. Part4.TopSurface = Enum.SurfaceType.Smooth
  56. Part4.brickColor = BrickColor.new("Institutional white")
  57. Part5.Name = "led"
  58. Part5.Parent = Tool0
  59. Part5.CFrame = CFrame.new(-8.61000061, 4.25000429, -14.0999937, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  60. Part5.Orientation = Vector3.new(0, 180, 0)
  61. Part5.Position = Vector3.new(-8.61000061, 4.25000429, -14.0999937)
  62. Part5.Rotation = Vector3.new(-180, 0, -180)
  63. Part5.Color = Color3.new(0.972549, 0.972549, 0.972549)
  64. Part5.Size = Vector3.new(0.0700000077, 0.699999988, 0.699999988)
  65. Part5.BottomSurface = Enum.SurfaceType.Smooth
  66. Part5.BrickColor = BrickColor.new("Institutional white")
  67. Part5.Locked = true
  68. Part5.Material = Enum.Material.Neon
  69. Part5.TopSurface = Enum.SurfaceType.Smooth
  70. Part5.brickColor = BrickColor.new("Institutional white")
  71.  
  72. local plr = owner
  73. local char = plr.Character
  74. local hum = char:FindFirstChildOfClass("Humanoid")
  75.  
  76. local tool = Tool0
  77. local handle = nil
  78.  
  79. local led = {}
  80.  
  81. for i,v in pairs(tool:GetChildren()) do
  82.     if v:IsA("BasePart") or v:IsA("UnionOperation") --[[and v:CanSetNetworkOwnership()]] then
  83.         v.CanCollide = false
  84.         --v:SetNetworkOwner(plr)
  85.     end
  86.     if v.Name == 'Handle' then
  87.         handle = v
  88.     elseif v.Name == 'led' then
  89.         table.insert(led,1,v)
  90.     end
  91. end
  92.  
  93. for i,v in pairs(tool:GetChildren()) do
  94.     if v ~= handle then
  95.         local weld = Instance.new("Weld")
  96.         weld.Part0 = handle
  97.         weld.Part1 = v
  98.         weld.C0 = handle.CFrame:Inverse()
  99.         weld.C1 = v.CFrame:Inverse()
  100.         weld.Parent = v
  101.     end
  102. end
  103.  
  104. local mrd1,mrd2,mrd3 = math.random(300,400),math.random(600,700),math.random(400,600)
  105. local prefix = '/'
  106. local songid = 0
  107. local volume = 1
  108. local speed = 1
  109. local last_time = 0
  110. local loudness = 0
  111. local looped = true
  112. local playing = false
  113. local bassing = {}
  114. local origin_size = Vector3.new(3,3,3)
  115. local max_size = Vector3.new(4.5,4.5,4.5)
  116. local ls
  117. local songval,remote,ls,song
  118.  
  119. function create_nls_remote()
  120.     if (owner or plr) then else return end
  121.     if not remote or not remote.Parent then
  122.         remote = Instance.new("RemoteEvent")
  123.         remote.Parent = (owner or plr)['PlayerGui']
  124.         songval = Instance.new("ObjectValue")
  125.         songval.Name = 'songval'
  126.         songval.Value = song
  127.         songval.Parent = remote
  128.         remote.OnServerEvent:Connect(function(lplr,loud)
  129.             loudness = loud
  130.         end)
  131.     end
  132.     if not ls or not ls.Parent then
  133.         NLS([[
  134.             local remote = script.Parent
  135.             local objval,song
  136.            
  137.             game:GetService("RunService").RenderStepped:Connect(function()
  138.                 if not objval or not objval.Parent then
  139.                     objval = remote:FindFirstChild('songval')
  140.                 end
  141.                 if objval and not song or not song.Parent then
  142.                     repeat wait() until objval.Value
  143.                     song = objval.Value
  144.                 end
  145.                 if song and song.Parent then
  146.                     remote:FireServer(song.PlaybackLoudness)
  147.                     wait(0.1)
  148.                 end
  149.             end)
  150.         ]],remote)
  151.         ls = remote:FindFirstChildOfClass('LocalScript')
  152.     end
  153. end
  154.  
  155. function chat(hplr)
  156.     hplr.Chatted:Connect(function(msg)
  157.         if hplr == plr then
  158.             if msg:lower():sub(1,4) == "vol" ..prefix then
  159.                 local choice = msg:sub(5)
  160.                 if tonumber(choice) then
  161.                     volume = choice
  162.                     song.Volume = choice
  163.                 end
  164.             end
  165.             --
  166.             if msg:lower():sub(1,7) == "/e vol" ..prefix then
  167.                 local choice = msg:sub(8)
  168.                 if tonumber(choice) then
  169.                     volume = choice
  170.                     song.Volume = choice
  171.                 end
  172.             end
  173.             --[[
  174.             if msg:lower():sub(1,5) == "loop" ..prefix then
  175.                 local choice = msg:sub(6)
  176.                 if choice == "false" then
  177.                     looped = false
  178.                     song.Looped = false
  179.                 elseif choice == "true" then
  180.                     looped = true
  181.                     song.Looped = true
  182.                 end
  183.             end
  184.             --
  185.             if msg:lower():sub(1,8) == "/e loop" ..prefix then
  186.                 local choice = msg:sub(9)
  187.                 if choice == "false" then
  188.                     looped = false
  189.                     song.Looped = false
  190.                 elseif choice == "true" then
  191.                     looped = true
  192.                     song.Looped = true
  193.                 end
  194.             end
  195.             --]]
  196.             if msg:lower():sub(1,5) == "play" ..prefix then
  197.                 songid = msg:sub(6)
  198.                 if tonumber(songid) then
  199.                     last_time = 0
  200.                     song.TimePosition = 0
  201.                     song.SoundId = 'rbxassetid://' .. songid
  202.                     song:Destroy()
  203.                 end
  204.             end
  205.             --
  206.             if msg:lower():sub(1,8) == "/e play" ..prefix then
  207.                 songid = msg:sub(9)
  208.                 if tonumber(songid) then
  209.                     last_time = 0
  210.                     song.TimePosition = 0
  211.                     song.SoundId = 'rbxassetid://' .. songid
  212.                     song:Destroy()
  213.                 end
  214.             end
  215.             --[[
  216.             if msg:lower():sub(1,5) == "stop" ..prefix then
  217.                 song:Stop()
  218.             end
  219.             --
  220.             if msg:lower():sub(1,8) == "/e stop" ..prefix then
  221.                 song:Stop()
  222.             end
  223.             --
  224.             if msg:lower():sub(1,6) == "pause" ..prefix then
  225.                 song:Pause()
  226.             end
  227.             --
  228.             if msg:lower():sub(1,9) == "/e pause" ..prefix then
  229.                 song:Pause()
  230.             end
  231.             --
  232.             if msg:lower():sub(1,7) == "resume" ..prefix then
  233.                 song:Resume()
  234.             end
  235.             --
  236.             if msg:lower():sub(1,10) == "/e resume" ..prefix then
  237.                 song:Resume()
  238.             end
  239.             --]]
  240.             if msg:lower():sub(1,5) == "skip" ..prefix then
  241.                 local t = msg:sub(6)
  242.                 if tonumber(t) then
  243.                     last_time = t
  244.                     song.TimePosition = t
  245.                 end
  246.             end
  247.             --
  248.             if msg:lower():sub(1,8) == "/e skip" ..prefix then
  249.                 local t = msg:sub(9)
  250.                 if tonumber(t) then
  251.                     last_time = t
  252.                     song.TimePosition = t
  253.                 end
  254.             end
  255.             if msg:lower():sub(1,6) == "speed" ..prefix then
  256.                 local choice = msg:lower():sub(7)
  257.                 if tonumber(choice) then
  258.                     speed = choice
  259.                     song.PlaybackSpeed = tonumber(speed)
  260.                 end
  261.             end
  262.             --
  263.             if msg:lower():sub(1,9) == "/e speed" ..prefix then
  264.                 local choice = msg:lower():sub(10)
  265.                 if tonumber(choice) then
  266.                     speed = choice
  267.                     song.PlaybackSpeed = tonumber(speed)
  268.                 end
  269.             end
  270.             --
  271.         end
  272.     end)
  273. end
  274.  
  275. function recolor(p)
  276.     if p then else return end
  277.     game:GetService("TweenService"):Create(p,TweenInfo.new(0.5),{Color = Color3.new(loudness / mrd1,loudness / mrd2,loudness / mrd3)}):Play()
  278. end
  279.  
  280. function add_bass_shadow(part)
  281.     if not bassing[part] then else return end
  282.     bassing[part] = true
  283.     local shadow = Instance.new("Part")
  284.     shadow.Anchored = true
  285.     shadow.CanCollide = false
  286.     shadow.Locked = true
  287.     shadow.Transparency = 0.4
  288.     shadow.Material = Enum.Material.ForceField
  289.     shadow.Position = part.Position
  290.     shadow.Size = Vector3.new(1.6,1.6,1.6)
  291.     local sphere = Instance.new("SpecialMesh")
  292.     sphere.MeshType = Enum.MeshType.Sphere
  293.     sphere.Parent = shadow
  294.     local emit = Instance.new("ParticleEmitter")
  295.     emit.Rotation = NumberRange.new(0, 360)
  296.     emit.Color = ColorSequence.new(Color3.new(1, 0.878431, 0.431373),part.Color)
  297.     emit.LightEmission = 0.4
  298.     emit.Texture = "rbxassetid://203216563"
  299.     emit.Transparency = NumberSequence.new(0.5,0.75,1)
  300.     emit.Size = NumberSequence.new(0.3125,0.5625,0.60509598255157,0.5,0.3821650147438)
  301.     emit.Lifetime = NumberRange.new(0.5, 0.75)
  302.     emit.Rate = 25
  303.     emit.RotSpeed = NumberRange.new(-500, 500)
  304.     emit.SpreadAngle = Vector2.new(360, 360)
  305.     emit.Speed = NumberRange.new(2, 3)
  306.     emit.Rotation = NumberRange.new(0, 360)
  307.     emit.LockedToPart = true
  308.     emit.Parent = shadow
  309.     shadow.Parent = workspace
  310.     coroutine.resume(coroutine.create(function()
  311.         emit.Enabled = true
  312.         wait(0.1)
  313.         emit.Enabled = false
  314.         bassing[part] = false
  315.         coroutine.yield()
  316.     end))
  317.     game:GetService("TweenService"):Create(shadow,TweenInfo.new(0.2),{Size = shadow.Size*2.1,Transparency = 1}):Play()
  318.     game:GetService("Debris"):AddItem(shadow,2)
  319. end
  320.  
  321. function bass(p)
  322.     local division_size = loudness/300
  323.     local make_size = origin_size+Vector3.new(division_size,division_size,division_size)
  324.     if make_size.Y > max_size.Y then
  325.         add_bass_shadow(p)
  326.     end
  327. end
  328.  
  329. function alive()
  330.     local r = false
  331.     if plr and plr.Parent and char and char.Parent and hum and hum.Parent and hum.Health > 0 then
  332.         r = true
  333.     end
  334.     return r
  335. end
  336.  
  337. tool.Equipped:Connect(function()
  338.     char = tool.Parent
  339.     plr = game:GetService("Players"):GetPlayerFromCharacter(char)
  340.     pcall(function()
  341.         hum = char:FindFirstChildOfClass("Humanoid")
  342.     end)
  343.     if alive() then
  344.         playing = true
  345.         chat(plr)
  346.     else
  347.         plr,char,hum = nil,nil,nil
  348.         tool.Parent = workspace
  349.         if tool.Parent ~= workspace then
  350.             playing = false
  351.         end
  352.     end
  353. end)
  354.  
  355. tool.Unequipped:Connect(function()
  356.     if tool.Parent ~= workspace then
  357.         playing = false
  358.     end
  359.     plr,char,hum = nil,nil,nil
  360. end)
  361.  
  362. warn([[
  363. -[ KrY's BlueTooth Speaker ]-
  364. -[ Commands while holding ]-
  365. - play/id
  366. - speed/number
  367. - skip/timestamp
  368. - vol/number
  369. ]])
  370.  
  371. spawn(function()
  372.     while wait(0.1) do
  373.         create_nls_remote()
  374.     end
  375. end)
  376.  
  377. game:GetService("RunService").Heartbeat:Connect(function()
  378.     pcall(function()
  379.         songval.Value = song
  380.         if not song or not song.Parent then
  381.             song = Instance.new("Sound")
  382.             song.SoundId = "rbxassetid://" .. songid
  383.             if playing then
  384.                 song.Volume = volume
  385.             else
  386.                 song.Volume = 0
  387.             end
  388.             song.Looped = true -- looped
  389.             song.PlaybackSpeed = speed
  390.             song.TimePosition = last_time
  391.             song.Parent = handle
  392.             song:Play()
  393.         end
  394.         if song then
  395.             if playing then
  396.                 song.Volume = volume
  397.             else
  398.                 song.Volume = 0
  399.             end
  400.             song.Looped = true -- looped
  401.             song.PlaybackSpeed = speed
  402.             song.Parent = handle
  403.             last_time = song.TimePosition
  404.             song:Resume()
  405.         end
  406.     end)
  407.     if playing then
  408.         bass(handle)
  409.         for i,v in pairs(led) do
  410.             recolor(v)
  411.         end
  412.     end
  413. end)
Add Comment
Please, Sign In to add comment