Advertisement
AvidMalignus

Roblox/Music player serverside.lua

May 19th, 2015
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.20 KB | None | 0 0
  1. local datastore = game:GetService("DataStoreService"):GetDataStore("anime")
  2.  
  3.  
  4. if not datastore:GetAsync("ms") then
  5. serverstore = datastore:SetAsync("ms",{})
  6. else
  7. serverstore = datastore:GetAsync("ms") 
  8. end
  9.  
  10. local player = owner or game:GetService("Players"):WaitForChild("Player1")
  11. player.Character:WaitForChild("Humanoid")
  12. local volume = 1
  13.  
  14. local _time = tick()
  15. local sound = Instance.new("Sound", workspace)
  16. sound.Volume = 1
  17. sound.Pitch = 1
  18. sound.Looped = false
  19. sound.PlayOnRemove = false
  20. sound.Archivable = true
  21.  
  22. local part = Instance.new("Part", player.Character)
  23. part.FormFactor = "Custom"
  24. part.Size = Vector3.new(33,15,.1)
  25. part.Anchored = true
  26. part.Locked = true
  27.  
  28.  
  29. local surface = Instance.new("SurfaceGui", part)
  30. q2 = Instance.new('Frame',surface)
  31. q2.BackgroundColor3 = Color3.new(0.364706, 0.376471, 0.411765)
  32. q2.BackgroundTransparency = 0
  33. q2.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843)
  34. q2.BorderSizePixel = 1
  35. q2.Name = 'Frame'
  36. q2.Position = UDim2.new(0,0,0,0)
  37. q2.Rotation = 0
  38. q2.Size = UDim2.new(1,0,1,0)
  39. q2.SizeConstraint = Enum.SizeConstraint.RelativeXY
  40. q2.Style = Enum.FrameStyle.Custom
  41. q2.Visible = true
  42. q2.ZIndex = 1
  43. q2.Archivable = true
  44. q2.ClipsDescendants = true
  45. q2.Draggable = false
  46. q2.Active = false
  47.  
  48. local background = Instance.new('ImageLabel',q2)
  49. background.BackgroundColor3 = Color3.new(1, 1, 1)
  50. background.BackgroundTransparency = 0
  51. background.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843)
  52. background.BorderSizePixel = 1
  53. background.Name = 'background'
  54. background.Position = UDim2.new(0,0,0,0)
  55. background.Rotation = 0
  56. background.Size = UDim2.new(1,0,1,0)
  57. background.SizeConstraint = Enum.SizeConstraint.RelativeXY
  58. background.Visible = true
  59. background.ZIndex = 1
  60. background.Archivable = true
  61. background.ClipsDescendants = false
  62. background.Draggable = false
  63. background.Image = 'http://www.roblox.com/asset/?id=246745840'
  64. background.ImageColor3 = Color3.new(1, 1, 1)
  65. background.ImageRectOffset = Vector2.new(0, 0)
  66. background.ImageRectSize = Vector2.new(0, 0)
  67. background.ImageTransparency = 0
  68. background.Active = false
  69.  
  70. q4 = Instance.new('Frame',q2)
  71. q4.BackgroundColor3 = Color3.new(0.109804, 0.109804, 0.121569)
  72. q4.BackgroundTransparency = 0
  73. q4.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843)
  74. q4.BorderSizePixel = 0
  75. q4.Name = 'Frame'
  76. q4.Position = UDim2.new(0,0,0,0)
  77. q4.Rotation = 0
  78. q4.Size = UDim2.new(0.050000000745058,0,1,0)
  79. q4.SizeConstraint = Enum.SizeConstraint.RelativeXY
  80. q4.Style = Enum.FrameStyle.Custom
  81. q4.Visible = true
  82. q4.ZIndex = 1
  83. q4.Archivable = true
  84. q4.ClipsDescendants = false
  85. q4.Draggable = false
  86. q4.Active = false
  87. q5 = Instance.new('ScrollingFrame',q2)
  88. q5.BackgroundColor3 = Color3.new(0.0666667, 0.0705882, 0.0745098)
  89. q5.BackgroundTransparency = 0.40000000596046
  90. q5.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843)
  91. q5.BorderSizePixel = 0
  92. q5.Name = 'ScrollingFrame'
  93. q5.Position = UDim2.new(0.050000000745058,0,0,0)
  94. q5.Rotation = 0
  95. q5.Size = UDim2.new(0.95,0,1,0)
  96. q5.SizeConstraint = Enum.SizeConstraint.RelativeXY
  97. q5.Visible = true
  98. q5.ZIndex = 1
  99. q5.Archivable = true
  100. q5.ClipsDescendants = true
  101. q5.Draggable = false
  102. q5.Active = false
  103. q5.BottomImage = 'http://www.roblox.com/asset/?id=247415456'
  104. q5.CanvasSize = UDim2.new(2,0,0,0)
  105. q5.CanvasPosition = Vector2.new(0,0)
  106. q5.MidImage = 'http://www.roblox.com/asset/?id=247415456'
  107. q5.TopImage = 'http://www.roblox.com/asset/?id=247415456'
  108.  
  109.  
  110.  
  111. -------------------------------------------------------------------------
  112.  
  113.  
  114.  
  115.  
  116. local backgroundrefresh = true
  117.  
  118.  
  119. local function load(name,soundid,decalid)
  120. local frame = Instance.new('ImageButton',q5)
  121. frame.BackgroundColor3 = Color3.new(1, 1, 1)
  122. frame.BackgroundTransparency = 0
  123. frame.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843)
  124. frame.BorderSizePixel = 1
  125. frame.Name = 'ImageLabel'
  126. frame.Rotation = 0
  127. frame.Position = UDim2.new(0,#q5:children()*120 - 100,0,100)
  128. frame.Size = UDim2.new(0,100,0,120)
  129. frame.SizeConstraint = Enum.SizeConstraint.RelativeXY
  130. frame.Visible = true
  131. frame.ZIndex = 1
  132. frame.Archivable = true
  133. frame.ClipsDescendants = false
  134. frame.Draggable = false
  135. frame.Image = 'http://www.roblox.com/asset/?id='..decalid
  136. frame.ImageColor3 = Color3.new(1, 1, 1)
  137. frame.ImageRectOffset = Vector2.new(0, 0)
  138. frame.ImageRectSize = Vector2.new(0, 0)
  139. frame.ImageTransparency = 0
  140. frame.Active = false
  141. local text = Instance.new('TextLabel',frame)
  142. text.BackgroundColor3 = Color3.new(0.133333, 0.137255, 0.14902)
  143. text.BackgroundTransparency = 0
  144. text.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843)
  145. text.BorderSizePixel = 0
  146. text.Name = 'TextLabel'
  147. text.Position = UDim2.new(0,0,1,0)
  148. text.Rotation = 0
  149. text.Size = UDim2.new(1,0,0.40000000596046,0)
  150. text.SizeConstraint = Enum.SizeConstraint.RelativeXY
  151. text.Visible = true
  152. text.ZIndex = 1
  153. text.Archivable = true
  154. text.ClipsDescendants = false
  155. text.Draggable = false
  156. text.Font = Enum.Font.SourceSans
  157. text.FontSize = Enum.FontSize.Size24
  158. text.Text = name
  159. text.TextColor3 = Color3.new(1, 1, 1)
  160. text.TextScaled = false
  161. text.TextStrokeColor3 = Color3.new(0, 0, 0)
  162. text.TextStrokeTransparency = 1
  163. text.TextTransparency = 0
  164. text.TextWrapped = true
  165. text.TextXAlignment = Enum.TextXAlignment.Center
  166. text.TextYAlignment = Enum.TextYAlignment.Center
  167. text.Active = false
  168. end
  169.  
  170.  
  171.  
  172. for k,v in pairs(serverstore) do
  173. load(v.Name,v.SoundId,v.DecalId)
  174. end
  175.  
  176. _G.sound = function(name,soundid,decalid)
  177.  
  178. if not name then
  179. name = "NONAME"
  180. elseif not soundid then
  181. soundid = 0
  182. elseif not decalid then
  183. decalid = 186730069
  184. end
  185. load(name,soundid,decalid)
  186. serverstore[#serverstore + 1] = {Name = name,SoundId = soundid,DecalId = decalid}
  187. datastore:SetAsync("ms",serverstore)
  188. end
  189.  
  190.  
  191.  
  192.  
  193.  
  194. local backgroundimg = {
  195. 246745840,
  196. 246745897,
  197. 246745919,
  198. 246745961,
  199. 246746023,
  200. 246746114,
  201. 246746158,
  202. 246746214
  203. }
  204.  
  205.  
  206. player.Chatted:connect(function(message)
  207. if string.sub(message,1,4):lower() == "play" then
  208. for k,v in pairs(serverstore) do
  209. if string.sub(v.Name:lower(),1,string.len(string.sub(message,6,string.len(message))))   == string.sub(message,6,string.len(message)):lower() then
  210. print(v.Name)
  211. if sound.IsPlaying == false then
  212. sound.SoundId = "rbxassetid://"..v.SoundId
  213. sound:Play()
  214. else
  215. sound:Stop()
  216. sound.SoundId = "rbxassetid://"..v.SoundId
  217. sound:Play()
  218. end
  219. end
  220. end
  221. elseif string.sub(message,1,6) == "volume" then
  222. volume = string.sub(message,7,string.len(message))
  223. sound.Volume = string.sub(message,7,string.len(message))
  224. end
  225. end)
  226.  
  227. local function backgroundref()
  228. repeat wait()
  229. for i=1, 8,1  do
  230. wait(.10)  
  231. background.Image = "http://www.roblox.com/asset/?id="..backgroundimg[i]
  232. end
  233. until backgroundrefresh == false
  234. end
  235.  
  236. coroutine.wrap(backgroundref)()
  237.  
  238.  
  239. local function update()
  240. pcall(function() part.CFrame = player.Character.Torso.CFrame *CFrame.new(0,7,-5) *CFrame.fromEulerAnglesXYZ(0,math.pi,0) end)
  241. end
  242.  
  243.  
  244. game:GetService("RunService").Heartbeat:connect(update)
  245.  
  246.  
  247. sound.Changed:connect(function()
  248. sound.Volume = volume
  249. sound.Parent = workspace
  250. sound.Pitch = 1
  251. sound.Looped = false
  252. sound.PlayOnRemove = false
  253. sound.Archivable = true
  254. end)
  255.  
  256. workspace.DescendantRemoving:connect(function(child)
  257. if child == sound then
  258. sound:Stop()   
  259. local a = Instance.new("Sound", workspace)
  260. sound = a  
  261. end
  262. end)
  263.  
  264. print("it took "..tick() - _time)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement