Advertisement
DarkScriptZEditors

Boombox

Dec 22nd, 2018
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.78 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  2. local Player,game,owner = owner,game
  3. local RealPlayer = Player
  4. do
  5. print("FE Compatibility code by Mokiros")
  6. local rp = RealPlayer
  7. script.Parent = rp.Character
  8.  
  9. --RemoteEvent for communicating
  10. local Event = Instance.new("RemoteEvent")
  11. Event.Name = "UserInput_Event"
  12.  
  13. --Fake event to make stuff like Mouse.KeyDown work
  14. local function fakeEvent()
  15. local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
  16. t.connect = t.Connect
  17. return t
  18. end
  19.  
  20. --Creating fake input objects with fake variables
  21. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  22. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  23. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  24. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  25. end}
  26. --Merged 2 functions into one by checking amount of arguments
  27. CAS.UnbindAction = CAS.BindAction
  28.  
  29. --This function will trigger the events that have been :Connect()'ed
  30. local function te(self,ev,...)
  31. local t = m[ev]
  32. if t and t._fakeEvent then
  33. for _,f in pairs(t.Functions) do
  34. f(...)
  35. end
  36. end
  37. end
  38. m.TrigEvent = te
  39. UIS.TrigEvent = te
  40.  
  41. Event.OnServerEvent:Connect(function(plr,io)
  42. if plr~=rp then return end
  43. m.Target = io.Target
  44. m.Hit = io.Hit
  45. if not io.isMouse then
  46. local b = io.UserInputState == Enum.UserInputState.Begin
  47. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  48. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  49. end
  50. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  51. return m:TrigEvent(b and "Button2Down" or "Button2Up")
  52. end
  53. for _,t in pairs(CAS.Actions) do
  54. for _,k in pairs(t.Keys) do
  55. if k==io.KeyCode then
  56. t.Function(t.Name,io.UserInputState,io)
  57. end
  58. end
  59. end
  60. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  61. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  62. end
  63. end)
  64. Event.Parent = NLS([==[
  65. local Player = game:GetService("Players").LocalPlayer
  66. local Event = script:WaitForChild("UserInput_Event")
  67. local Mouse = Player:GetMouse()
  68. local UIS = game:GetService("UserInputService")
  69. local input = function(io,a)
  70. if a then return end
  71. --Since InputObject is a client-side instance, we create and pass table instead
  72. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  73. end
  74. UIS.InputBegan:Connect(input)
  75. UIS.InputEnded:Connect(input)
  76. local h,t
  77. --Give the server mouse data 30 times every second, but only if the values changed
  78. --If player is not moving their mouse, client won't fire events
  79. while wait(1/30) do
  80. if h~=Mouse.Hit or t~=Mouse.Target then
  81. h,t=Mouse.Hit,Mouse.Target
  82. Event:FireServer({isMouse=true,Target=t,Hit=h})
  83. end
  84. end]==],Player.Character)
  85.  
  86. ----Sandboxed game object that allows the usage of client-side methods and services
  87. --Real game object
  88. local _rg = game
  89.  
  90. --Metatable for fake service
  91. local fsmt = {
  92. __index = function(self,k)
  93. local s = rawget(self,"_RealService")
  94. if s then
  95. return typeof(s[k])=="function"
  96. and function(_,...)return s[k](s,...)end or s[k]
  97. end
  98. end,
  99. __newindex = function(self,k,v)
  100. local s = rawget(self,"_RealService")
  101. if s then s[k]=v end
  102. end
  103. }
  104. local function FakeService(t,RealService)
  105. t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  106. return setmetatable(t,fsmt)
  107. end
  108.  
  109. --Fake game object
  110. local g = {
  111. GetService = function(self,s)
  112. return rawget(self,s) or _rg:GetService(s)
  113. end,
  114. Players = FakeService({
  115. LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  116. },"Players"),
  117. UserInputService = FakeService(UIS,"UserInputService"),
  118. ContextActionService = FakeService(CAS,"ContextActionService"),
  119. RunService = FakeService({
  120. _btrs = {},
  121. RenderStepped = _rg:GetService("RunService").Heartbeat,
  122. BindToRenderStep = function(self,name,_,fun)
  123. self._btrs[name] = self.Heartbeat:Connect(fun)
  124. end,
  125. UnbindFromRenderStep = function(self,name)
  126. self._btrs[name]:Disconnect()
  127. end,
  128. },"RunService")
  129. }
  130. rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  131. g.service = g.GetService
  132. FakeService(g,game)
  133. --Changing owner to fake player object to support owner:GetMouse()
  134. game,owner = g,g.Players.LocalPlayer
  135. end
  136. -- GPlayr by ModernLukest. Made for v3rmillion, , etc.
  137. -- Note that anyone can hear the music that you play. Just a clarification for what LocalScripts can do.
  138.  
  139. local char = game.Players.LocalPlayer.Character
  140.  
  141.  
  142.  
  143. -- CREATING BUTTONS, LABELS, FRAMES, ETC.
  144. local gui = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui) -- CoreGui is buggy, since GPlayr is designed for PlayerGuis, not CoreGuis.
  145. local openbtn = Instance.new("TextButton", gui)
  146. local closebtn = Instance.new("TextButton", gui)
  147. local openguibtn = Instance.new("TextButton", gui)
  148. local playmusicint = Instance.new("Frame", gui)
  149. local playmusicbtn = Instance.new("ImageButton", playmusicint)
  150. local stopmusicbtn = Instance.new("ImageButton", playmusicint)
  151. local musicidbox = Instance.new("TextBox", playmusicint)
  152. local credit = Instance.new("TextLabel", playmusicint)
  153. local title = Instance.new("TextLabel", playmusicint)
  154.  
  155. -- SIZING --
  156.  
  157. openbtn.Size = UDim2.new(0, 100, 0, 50)
  158. closebtn.Size = UDim2.new(0, 100, 0, 50)
  159. openguibtn.Size = UDim2.new(0, 100, 0, 50)
  160. playmusicbtn.Size = UDim2.new(0, 50, 0, 50)
  161. stopmusicbtn.Size = UDim2.new(0, 57, 0, 57)
  162. musicidbox.Size = UDim2.new(0, 300, 0, 50)
  163. credit.Size = UDim2.new(0, 300, 0, 20)
  164. title.Size = UDim2.new(0, 300, 0, 30)
  165. playmusicint.Size = UDim2.new(0, 300, 0, 500)
  166.  
  167. -- POSITIONING --
  168.  
  169. openbtn.Position = UDim2.new(0, 0, 0, 510)
  170. closebtn.Position = UDim2.new(0, 0, 0, 510)
  171. openguibtn.Position = UDim2.new(0, 0, 0, 590)
  172. playmusicbtn.Position = UDim2.new(0, 50, 0, 200)
  173. stopmusicbtn.Position = UDim2.new(0, 175, 0, 197)
  174. musicidbox.Position = UDim2.new(0, 0, 0, 100)
  175. credit.Position = UDim2.new(0, 0, 0, 470)
  176. title.Position = UDim2.new(0, 0, 0, 0)
  177. playmusicint.Position = UDim2.new(0, 200, 0, 100)
  178.  
  179. -- SET TEXT --
  180.  
  181. title.Text = "GPlayr (BETA)"
  182. credit.Text = "GPlayr & radio scripting by Developer / ModernLukest"
  183. musicidbox.Text = "Enter Sound ID Here"
  184. openbtn.Text = "Take Out Radio"
  185. closebtn.Text = "Put Away Radio"
  186. openguibtn.Text = "Open/Close Music GUI"
  187.  
  188. -- SET IMAGE IDS --
  189. playmusicbtn.Image = "rbxassetid://499381047"
  190. stopmusicbtn.Image = "rbxassetid://499381006"
  191.  
  192. -- BACKGROUND COLOR3 --
  193.  
  194. playmusicint.BackgroundColor3 = Color3.new(136, 136, 136)
  195. openbtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  196. closebtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  197. openguibtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  198. musicidbox.BackgroundColor3 = Color3.fromRGB(109, 109, 109)
  199.  
  200. -- BACKGROUND TRANSPARENCY --
  201.  
  202. playmusicint.BackgroundTransparency = 0.9
  203. playmusicbtn.BackgroundTransparency = 1
  204. stopmusicbtn.BackgroundTransparency = 1
  205. musicidbox.BackgroundTransparency = 0.43
  206. credit.BackgroundTransparency = 1
  207. title.BackgroundTransparency = 1
  208.  
  209. -- BORDER SIZE PIXEL --
  210.  
  211. musicidbox.BorderSizePixel = 0
  212. openbtn.BorderSizePixel = 3
  213. closebtn.BorderSizePixel = 3
  214. openguibtn.BorderSizePixel = 3
  215.  
  216. -- FONTS --
  217. musicidbox.Font = "SourceSansLight"
  218. credit.Font = "SourceSansLight"
  219. title.Font = "SourceSansLight"
  220.  
  221.  
  222. -- TEXT SCALED --
  223. credit.TextScaled = true
  224. title.TextScaled = true
  225.  
  226. -- TEXT WRAPPED --
  227. musicidbox.TextWrapped = true
  228. credit.TextWrapped = true
  229. title.TextWrapped = true
  230. openguibtn.TextWrapped = true
  231.  
  232. -- FONT SIZE --
  233. musicidbox.FontSize = "Size28"
  234.  
  235. -- ACTIVE --
  236. playmusicint.Active = true
  237.  
  238. -- DRAGGABLE --
  239. playmusicint.Draggable = true
  240.  
  241. -- GUI FUNCTIONS (MAIN) --
  242.  
  243. -- set up the stuff --
  244. isGuiOpen = false
  245. closebtn.Visible = false
  246. playmusicint.Visible = false
  247. openguibtn.Visible = false
  248.  
  249. openbtn.MouseButton1Click:connect(function()
  250. openbtn.Visible = false
  251. closebtn.Visible = true
  252.  
  253. local radio = Instance.new("Part", char)
  254. radio.Name = "Radio"
  255. local mesh = Instance.new("FileMesh", radio)
  256. mesh.MeshId = "http://www.roblox.com/asset/?id=212302951"
  257. mesh.TextureId = "http://www.roblox.com/asset/?id=212303049"
  258. mesh.Scale = Vector3.new(4, 4, 4)
  259. mesh.VertexColor = Vector3.new(1, 1, 1)
  260. mesh.Offset = Vector3.new(0, 0, 0)
  261.  
  262.  
  263. local function weldBetween(a, b)
  264. local weld = Instance.new("ManualWeld")
  265. weld.Part0 = a
  266. weld.Part1 = b
  267. weld.C0 = CFrame.new()
  268. weld.C1 = b.CFrame:inverse() * a.CFrame
  269. weld.Parent = a
  270. return weld;
  271. end
  272. local hand = radio:clone()
  273. hand.Parent=char
  274. hand.CFrame=char:WaitForChild("Torso").CFrame*CFrame.new(Vector3.new(0,0,0.9))*CFrame.Angles(0,math.rad(180),math.rad(45))
  275. weldBetween(char:WaitForChild("Torso"), hand)
  276. hand.CanCollide=true
  277. hand.Anchored=false
  278.  
  279. sound = Instance.new("Sound", hand) -- we will now call the radio "hand"
  280. sound.Volume = 0.5
  281. sound.Pitch = 1
  282.  
  283. openguibtn.Visible = true
  284. char:FindFirstChild("Radio"):Destroy()
  285. end)
  286.  
  287.  
  288. closebtn.MouseButton1Click:connect(function()
  289. openbtn.Visible = true
  290. closebtn.Visible = false
  291. openguibtn.Visible = false
  292. playmusicint.Visible = false
  293. isGuiOpen = false
  294. char:WaitForChild("Radio"):Destroy()
  295. end)
  296.  
  297. playmusicbtn.MouseButton1Click:connect(function()
  298. sound:stop()
  299. wait(0.2)
  300. sound.SoundId = "rbxassetid://"..musicidbox.Text
  301. sound:play()
  302. end)
  303.  
  304. stopmusicbtn.MouseButton1Click:connect(function()
  305. sound:stop()
  306. end)
  307.  
  308.  
  309. openguibtn.MouseButton1Click:connect(function()
  310. if isGuiOpen == false then isGuiOpen = true
  311. playmusicint.Visible = true else isGuiOpen = false playmusicint.Visible = false
  312. end
  313. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement