Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,game,owner = owner,game
- local RealPlayer = Player
- do
- print("FE Compatibility code by Mokiros")
- local rp = RealPlayer
- script.Parent = rp.Character
- --RemoteEvent for communicating
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- --Fake event to make stuff like Mouse.KeyDown work
- local function fakeEvent()
- local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
- t.connect = t.Connect
- return t
- end
- --Creating fake input objects with fake variables
- local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
- CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
- end}
- --Merged 2 functions into one by checking amount of arguments
- CAS.UnbindAction = CAS.BindAction
- --This function will trigger the events that have been :Connect()'ed
- local function te(self,ev,...)
- local t = m[ev]
- if t and t._fakeEvent then
- for _,f in pairs(t.Functions) do
- f(...)
- end
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=rp then return end
- m.Target = io.Target
- m.Hit = io.Hit
- if not io.isMouse then
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return m:TrigEvent(b and "Button1Down" or "Button1Up")
- end
- if io.UserInputType == Enum.UserInputType.MouseButton2 then
- return m:TrigEvent(b and "Button2Down" or "Button2Up")
- end
- for _,t in pairs(CAS.Actions) do
- for _,k in pairs(t.Keys) do
- if k==io.KeyCode then
- t.Function(t.Name,io.UserInputState,io)
- end
- end
- end
- m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[
- local Player = game:GetService("Players").LocalPlayer
- local Event = script:WaitForChild("UserInput_Event")
- local Mouse = Player:GetMouse()
- local UIS = game:GetService("UserInputService")
- local input = function(io,a)
- if a then return end
- --Since InputObject is a client-side instance, we create and pass table instead
- Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local h,t
- --Give the server mouse data 30 times every second, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- while wait(1/30) do
- if h~=Mouse.Hit or t~=Mouse.Target then
- h,t=Mouse.Hit,Mouse.Target
- Event:FireServer({isMouse=true,Target=t,Hit=h})
- end
- end]==],Player.Character)
- ----Sandboxed game object that allows the usage of client-side methods and services
- --Real game object
- local _rg = game
- --Metatable for fake service
- local fsmt = {
- __index = function(self,k)
- local s = rawget(self,"_RealService")
- if s then
- return typeof(s[k])=="function"
- and function(_,...)return s[k](s,...)end or s[k]
- end
- end,
- __newindex = function(self,k,v)
- local s = rawget(self,"_RealService")
- if s then s[k]=v end
- end
- }
- local function FakeService(t,RealService)
- t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
- return setmetatable(t,fsmt)
- end
- --Fake game object
- local g = {
- GetService = function(self,s)
- return rawget(self,s) or _rg:GetService(s)
- end,
- Players = FakeService({
- LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
- },"Players"),
- UserInputService = FakeService(UIS,"UserInputService"),
- ContextActionService = FakeService(CAS,"ContextActionService"),
- RunService = FakeService({
- _btrs = {},
- RenderStepped = _rg:GetService("RunService").Heartbeat,
- BindToRenderStep = function(self,name,_,fun)
- self._btrs[name] = self.Heartbeat:Connect(fun)
- end,
- UnbindFromRenderStep = function(self,name)
- self._btrs[name]:Disconnect()
- end,
- },"RunService")
- }
- rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
- g.service = g.GetService
- FakeService(g,game)
- --Changing owner to fake player object to support owner:GetMouse()
- game,owner = g,g.Players.LocalPlayer
- end
- -- GPlayr by ModernLukest. Made for v3rmillion, , etc.
- -- Note that anyone can hear the music that you play. Just a clarification for what LocalScripts can do.
- local char = game.Players.LocalPlayer.Character
- -- CREATING BUTTONS, LABELS, FRAMES, ETC.
- local gui = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui) -- CoreGui is buggy, since GPlayr is designed for PlayerGuis, not CoreGuis.
- local openbtn = Instance.new("TextButton", gui)
- local closebtn = Instance.new("TextButton", gui)
- local openguibtn = Instance.new("TextButton", gui)
- local playmusicint = Instance.new("Frame", gui)
- local playmusicbtn = Instance.new("ImageButton", playmusicint)
- local stopmusicbtn = Instance.new("ImageButton", playmusicint)
- local musicidbox = Instance.new("TextBox", playmusicint)
- local credit = Instance.new("TextLabel", playmusicint)
- local title = Instance.new("TextLabel", playmusicint)
- -- SIZING --
- openbtn.Size = UDim2.new(0, 100, 0, 50)
- closebtn.Size = UDim2.new(0, 100, 0, 50)
- openguibtn.Size = UDim2.new(0, 100, 0, 50)
- playmusicbtn.Size = UDim2.new(0, 50, 0, 50)
- stopmusicbtn.Size = UDim2.new(0, 57, 0, 57)
- musicidbox.Size = UDim2.new(0, 300, 0, 50)
- credit.Size = UDim2.new(0, 300, 0, 20)
- title.Size = UDim2.new(0, 300, 0, 30)
- playmusicint.Size = UDim2.new(0, 300, 0, 500)
- -- POSITIONING --
- openbtn.Position = UDim2.new(0, 0, 0, 510)
- closebtn.Position = UDim2.new(0, 0, 0, 510)
- openguibtn.Position = UDim2.new(0, 0, 0, 590)
- playmusicbtn.Position = UDim2.new(0, 50, 0, 200)
- stopmusicbtn.Position = UDim2.new(0, 175, 0, 197)
- musicidbox.Position = UDim2.new(0, 0, 0, 100)
- credit.Position = UDim2.new(0, 0, 0, 470)
- title.Position = UDim2.new(0, 0, 0, 0)
- playmusicint.Position = UDim2.new(0, 200, 0, 100)
- -- SET TEXT --
- title.Text = "GPlayr (BETA)"
- credit.Text = "GPlayr & radio scripting by Developer / ModernLukest"
- musicidbox.Text = "Enter Sound ID Here"
- openbtn.Text = "Take Out Radio"
- closebtn.Text = "Put Away Radio"
- openguibtn.Text = "Open/Close Music GUI"
- -- SET IMAGE IDS --
- playmusicbtn.Image = "rbxassetid://499381047"
- stopmusicbtn.Image = "rbxassetid://499381006"
- -- BACKGROUND COLOR3 --
- playmusicint.BackgroundColor3 = Color3.new(136, 136, 136)
- openbtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- closebtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- openguibtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- musicidbox.BackgroundColor3 = Color3.fromRGB(109, 109, 109)
- -- BACKGROUND TRANSPARENCY --
- playmusicint.BackgroundTransparency = 0.9
- playmusicbtn.BackgroundTransparency = 1
- stopmusicbtn.BackgroundTransparency = 1
- musicidbox.BackgroundTransparency = 0.43
- credit.BackgroundTransparency = 1
- title.BackgroundTransparency = 1
- -- BORDER SIZE PIXEL --
- musicidbox.BorderSizePixel = 0
- openbtn.BorderSizePixel = 3
- closebtn.BorderSizePixel = 3
- openguibtn.BorderSizePixel = 3
- -- FONTS --
- musicidbox.Font = "SourceSansLight"
- credit.Font = "SourceSansLight"
- title.Font = "SourceSansLight"
- -- TEXT SCALED --
- credit.TextScaled = true
- title.TextScaled = true
- -- TEXT WRAPPED --
- musicidbox.TextWrapped = true
- credit.TextWrapped = true
- title.TextWrapped = true
- openguibtn.TextWrapped = true
- -- FONT SIZE --
- musicidbox.FontSize = "Size28"
- -- ACTIVE --
- playmusicint.Active = true
- -- DRAGGABLE --
- playmusicint.Draggable = true
- -- GUI FUNCTIONS (MAIN) --
- -- set up the stuff --
- isGuiOpen = false
- closebtn.Visible = false
- playmusicint.Visible = false
- openguibtn.Visible = false
- openbtn.MouseButton1Click:connect(function()
- openbtn.Visible = false
- closebtn.Visible = true
- local radio = Instance.new("Part", char)
- radio.Name = "Radio"
- local mesh = Instance.new("FileMesh", radio)
- mesh.MeshId = "http://www.roblox.com/asset/?id=212302951"
- mesh.TextureId = "http://www.roblox.com/asset/?id=212303049"
- mesh.Scale = Vector3.new(4, 4, 4)
- mesh.VertexColor = Vector3.new(1, 1, 1)
- mesh.Offset = Vector3.new(0, 0, 0)
- local function weldBetween(a, b)
- local weld = Instance.new("ManualWeld")
- weld.Part0 = a
- weld.Part1 = b
- weld.C0 = CFrame.new()
- weld.C1 = b.CFrame:inverse() * a.CFrame
- weld.Parent = a
- return weld;
- end
- local hand = radio:clone()
- hand.Parent=char
- hand.CFrame=char:WaitForChild("Torso").CFrame*CFrame.new(Vector3.new(0,0,0.9))*CFrame.Angles(0,math.rad(180),math.rad(45))
- weldBetween(char:WaitForChild("Torso"), hand)
- hand.CanCollide=true
- hand.Anchored=false
- sound = Instance.new("Sound", hand) -- we will now call the radio "hand"
- sound.Volume = 0.5
- sound.Pitch = 1
- openguibtn.Visible = true
- char:FindFirstChild("Radio"):Destroy()
- end)
- closebtn.MouseButton1Click:connect(function()
- openbtn.Visible = true
- closebtn.Visible = false
- openguibtn.Visible = false
- playmusicint.Visible = false
- isGuiOpen = false
- char:WaitForChild("Radio"):Destroy()
- end)
- playmusicbtn.MouseButton1Click:connect(function()
- sound:stop()
- wait(0.2)
- sound.SoundId = "rbxassetid://"..musicidbox.Text
- sound:play()
- end)
- stopmusicbtn.MouseButton1Click:connect(function()
- sound:stop()
- end)
- openguibtn.MouseButton1Click:connect(function()
- if isGuiOpen == false then isGuiOpen = true
- playmusicint.Visible = true else isGuiOpen = false playmusicint.Visible = false
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement