Upscalefanatic3

Radio Script (Voidacity Script Builder)

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