View difference between Paste ID: qELwd3NL and SJcQD3zX
SHOW: | | - or go back to the newest paste.
1-
-- GPlayr by ModernLukest. Made for v3rmillion, , etc.
1+
-- This script has been converted to FE by iPxter
2-
-- Note that anyone can hear the music that you play. Just a clarification for what LocalScripts can do.
2+
3
4-
local char = game.Players.LocalPlayer.Character
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-
local gui = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui) -- CoreGui is buggy, since GPlayr is designed for PlayerGuis, not CoreGuis.
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 = game:GetService("Players").LocalPlayer
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 Mouse = Player:GetMouse()
75
	local h,t
76
	--Give the server mouse data 30 times every second, but only if the values changed
77
	--If player is not moving their mouse, client won't fire events
78
	while wait(1/30) do
79
		if h~=Mouse.Hit or t~=Mouse.Target then
80
			h,t=Mouse.Hit,Mouse.Target
81
			Event:FireServer({isMouse=true,Target=t,Hit=h})
82
		end
83
	end]==],Player.Character)
84
	Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
85
end
86
87
local char = owner.Character
88
89
90
91
-- CREATING BUTTONS, LABELS, FRAMES, ETC.
92
local gui = Instance.new("ScreenGui", owner.PlayerGui) -- CoreGui is buggy, since GPlayr is designed for PlayerGuis, not CoreGuis.
93
local openbtn = Instance.new("TextButton", gui)
94
local closebtn = Instance.new("TextButton", gui)
95
local openguibtn = Instance.new("TextButton", gui)
96
local playmusicint = Instance.new("Frame", gui)
97
local playmusicbtn = Instance.new("ImageButton", playmusicint)
98
local stopmusicbtn = Instance.new("ImageButton", playmusicint)
99
local musicidbox = Instance.new("TextBox", playmusicint)
100
local credit = Instance.new("TextLabel", playmusicint)
101
local title = Instance.new("TextLabel", playmusicint)
102
103
-- SIZING --
104
105
openbtn.Size = UDim2.new(0, 100, 0, 50)
106
closebtn.Size = UDim2.new(0, 100, 0, 50)
107
openguibtn.Size = UDim2.new(0, 100, 0, 50)
108
playmusicbtn.Size = UDim2.new(0, 50, 0, 50)
109
stopmusicbtn.Size = UDim2.new(0, 57, 0, 57)
110
musicidbox.Size = UDim2.new(0, 300, 0, 50)
111
credit.Size = UDim2.new(0, 300, 0, 20)
112
title.Size = UDim2.new(0, 300, 0, 30)
113
playmusicint.Size = UDim2.new(0, 300, 0, 500)
114
115
-- POSITIONING --
116
117
openbtn.Position = UDim2.new(0, 0, 0, 510)
118
closebtn.Position = UDim2.new(0, 0, 0, 510)
119
openguibtn.Position = UDim2.new(0, 0, 0, 590)
120
playmusicbtn.Position = UDim2.new(0, 50, 0, 200)
121
stopmusicbtn.Position = UDim2.new(0, 175, 0, 197)
122
musicidbox.Position = UDim2.new(0, 0, 0, 100)
123
credit.Position = UDim2.new(0, 0, 0, 470)
124
title.Position = UDim2.new(0, 0, 0, 0)
125
playmusicint.Position = UDim2.new(0, 200, 0, 100)
126
127
-- SET TEXT --
128
129
title.Text = "GPlayr (BETA)"
130
credit.Text = "GPlayr & radio scripting by Developer / ModernLukest"
131
musicidbox.Text = "Enter Sound ID Here"
132
openbtn.Text = "Take Out Radio"
133
closebtn.Text = "Put Away Radio"
134
openguibtn.Text = "Open/Close Music GUI"
135
136
-- SET IMAGE IDS --
137
playmusicbtn.Image = "rbxassetid://499381047"
138
stopmusicbtn.Image = "rbxassetid://499381006"
139
140
-- BACKGROUND COLOR3 --
141
142
playmusicint.BackgroundColor3 = Color3.new(136, 136, 136)
143
openbtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
144
closebtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
145
openguibtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
146
musicidbox.BackgroundColor3 = Color3.fromRGB(109, 109, 109)
147
148
-- BACKGROUND TRANSPARENCY --
149
150
playmusicint.BackgroundTransparency = 0.9
151
playmusicbtn.BackgroundTransparency = 1
152
stopmusicbtn.BackgroundTransparency = 1
153
musicidbox.BackgroundTransparency = 0.43
154
credit.BackgroundTransparency = 1
155
title.BackgroundTransparency = 1
156
157
-- BORDER SIZE PIXEL --
158
159
musicidbox.BorderSizePixel = 0
160
openbtn.BorderSizePixel = 3
161
closebtn.BorderSizePixel = 3
162
openguibtn.BorderSizePixel = 3
163
164
-- FONTS --
165
musicidbox.Font = "SourceSansLight"
166
credit.Font = "SourceSansLight"
167
title.Font = "SourceSansLight"
168
169
170
-- TEXT SCALED --
171
credit.TextScaled = true
172
title.TextScaled = true
173
174
-- TEXT WRAPPED --
175
musicidbox.TextWrapped = true
176
credit.TextWrapped = true
177
title.TextWrapped = true
178
openguibtn.TextWrapped = true
179
180
-- FONT SIZE --
181
musicidbox.FontSize = "Size28"
182
183
-- ACTIVE --
184
playmusicint.Active = true
185
186
-- DRAGGABLE --
187
playmusicint.Draggable = true
188
189
-- GUI FUNCTIONS (MAIN) --
190
191
-- set up the stuff --
192
isGuiOpen = false
193
closebtn.Visible = false
194
playmusicint.Visible = false
195
openguibtn.Visible = false
196
197
openbtn.MouseButton1Click:connect(function()
198
openbtn.Visible = false
199
closebtn.Visible = true
200
201
local radio = Instance.new("Part", char)
202
radio.Name = "Radio"
203
local mesh = Instance.new("FileMesh", radio)
204
mesh.MeshId = "http://www.roblox.com/asset/?id=212302951"
205
mesh.TextureId = "http://www.roblox.com/asset/?id=212303049"
206
mesh.Scale = Vector3.new(4, 4, 4)
207
mesh.VertexColor = Vector3.new(1, 1, 1)
208
mesh.Offset = Vector3.new(0, 0, 0)
209
210
211
local function weldBetween(a, b)
212
   local weld = Instance.new("ManualWeld")
213
   weld.Part0 = a
214
   weld.Part1 = b
215
   weld.C0 = CFrame.new()
216
   weld.C1 = b.CFrame:inverse() * a.CFrame
217
   weld.Parent = a
218
   return weld;
219
end
220
local hand = radio:clone()
221
hand.Parent=char
222
hand.CFrame=char:WaitForChild("Torso").CFrame*CFrame.new(Vector3.new(0,0,0.9))*CFrame.Angles(0,math.rad(180),math.rad(45))
223
weldBetween(char:WaitForChild("Torso"), hand)
224
hand.CanCollide=true
225
hand.Anchored=false
226
227
sound = Instance.new("Sound", hand) -- we will now call the radio "hand"
228
sound.Volume = 0.5
229
sound.Pitch = 1
230
231
openguibtn.Visible = true
232
char:FindFirstChild("Radio"):Destroy()
233
end)
234
235
236
closebtn.MouseButton1Click:connect(function()
237
openbtn.Visible = true
238
closebtn.Visible = false
239
openguibtn.Visible = false
240
playmusicint.Visible = false
241
isGuiOpen = false
242
char:WaitForChild("Radio"):Destroy()
243
end)
244
245
playmusicbtn.MouseButton1Click:connect(function()
246
sound:stop()
247
wait(0.2)
248
sound.SoundId = "rbxassetid://"..musicidbox.Text
249
sound:play()
250
end)
251
252
stopmusicbtn.MouseButton1Click:connect(function()
253
sound:stop()
254
end)
255
256
257
openguibtn.MouseButton1Click:connect(function()
258
if isGuiOpen == false then isGuiOpen = true
259
playmusicint.Visible = true else isGuiOpen = false playmusicint.Visible = false
260
end
261
end)