Advertisement
UiiN2IPCEO

radio

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