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