R

fe bring gui

public
rrixh Mar 02, 2024 Never 317
Clone
Plaintext FEbringgui_lulaslollipop 432 lines (426 loc) | 10.29 KB
This code is a Lua script written for the Roblox platform. It creates a GUI for bringing players in a Roblox game closer to each other. Here's a summary of the main points in the given code: 1. The script initializes various variables to get game instances (like Players, Workspace), services (like UserInputService, RunService), functions, and constants. 2. The `gp` function is defined to find a child of a given instance by name and class. 3. Several instances like Frame, TextLabel, TextBox, TextButton, ScreenGui, etc., are created and configured to create a GUI window. 4. The `Draggable` function is defined to make the created window draggable. 5. The script maintains a list of other players in the game and listens to player-related events like PlayerAdded and PlayerRemoving. 6. The `findplr` function is defined to find a player based on the input string. 7. The GUI elements are updated based on the player selection. 8. The `notify` function displays a temporary notification on the screen. 9. The `bringing` functionality brings a selected player closer to the local player's character using velocity calculations. 10. The script tries to parent the GUI under CoreGui and falls back to PlayerGui. Overall, the code creates a GUI for selecting players and bringing them closer in a Roblox game environment. There are functions to manage player interactions, notifications, and the dragging behavior of the GUI window.
1
local plrs=game:FindFirstChildOfClass("Players")
2
local lp=plrs.LocalPlayer
3
local ws=game:FindFirstChildOfClass("Workspace")
4
local uis=game:FindFirstChildOfClass("UserInputService")
5
local rs=game:FindFirstChildOfClass("RunService")
6
local heartbeat=rs.Heartbeat
7
local renderstepped=rs.RenderStepped
8
local angles=CFrame.Angles
9
local cf=CFrame.new
10
local v3=Vector3.new
11
local v3_010=v3(0,1,0)
12
local v3_0=v3(0,0,0)
13
local osclock=os.clock
14
local twait=task.wait
15
local slower=string.lower
16
local ssub=string.sub
17
18
local speeding=32
19
local maxspeed=75
20
local off=angles(-1.5707963267948966,0,0)
21
22
local function gp(p,n,cl)
23
if typeof(p)=="Instance" then
24
local c=p:GetChildren()
25
for i=1,#c do
26
local v=c[i]
27
if (v.Name==n) and v:IsA(cl) then
28
return v
29
end
30
end
31
end
32
return nil
33
end
34
35
local i=Instance.new
36
local v2=Vector2.new
37
local bc=BrickColor.new
38
local c3=Color3.new
39
local u2=UDim2.new
40
local sc,mr=string.char,math.random
41
local function rs(l)
42
l=l or mr(8,15)
43
local s=""
44
for i=1,l do
45
if mr(1,2)==1 then
46
s=s..sc(mr(65,90))
47
else
48
s=s..sc(mr(97,122))
49
end
50
end
51
return s
52
end
53
local e=Enum
54
local i1=i("Frame")
55
local i2=i("TextLabel")
56
local i3=i("Frame")
57
local i4=i("TextBox")
58
local i5=i("TextButton")
59
local i6=i("TextLabel")
60
local i7=i("TextLabel")
61
local i8=i("ScreenGui")
62
i1.AnchorPoint=v2(0.5,0.5)
63
i1.BackgroundColor=bc(149)
64
i1.BackgroundColor3=c3(0.129412,0.129412,0.129412)
65
i1.BorderColor=bc(1003)
66
i1.BorderColor3=c3(0,0,0)
67
i1.BorderSizePixel=0
68
i1.Position=u2(0.5,0,0.5,0)
69
i1.Size=u2(0,250,0,140)
70
i1.Name=rs()
71
i1.Parent=i8
72
i2.Font=e.Font.SourceSans
73
i2.FontSize=e.FontSize.Size24
74
i2.Text="FE bring gui"
75
i2.TextColor=bc(1002)
76
i2.TextColor3=c3(0.815686,0.815686,0.815686)
77
i2.TextSize=20
78
i2.BackgroundColor=bc(1001)
79
i2.BackgroundColor3=c3(1,1,1)
80
i2.BackgroundTransparency=1
81
i2.BorderColor=bc(1003)
82
i2.BorderColor3=c3(0,0,0)
83
i2.BorderSizePixel=0
84
i2.Size=u2(1,0,0,25)
85
i2.Name=rs()
86
i2.Parent=i1
87
i3.BackgroundColor=bc(26)
88
i3.BackgroundColor3=c3(0.192157,0.192157,0.192157)
89
i3.BorderColor=bc(1003)
90
i3.BorderColor3=c3(0,0,0)
91
i3.BorderSizePixel=0
92
i3.ClipsDescendants=true
93
i3.Position=u2(0,5,0,25)
94
i3.Size=u2(1,-10,1,-30)
95
i3.Name=rs()
96
i3.Parent=i1
97
i4.CursorPosition=-1
98
i4.Font=e.Font.SourceSans
99
i4.FontSize=e.FontSize.Size24
100
i4.PlaceholderColor3=c3(0.509804,0.509804,0.509804)
101
i4.PlaceholderText="DisplayName/Name"
102
i4.Text=""
103
i4.TextColor=bc(1)
104
i4.TextColor3=c3(0.952941,0.952941,0.952941)
105
i4.TextSize=20
106
i4.TextWrap=true
107
i4.AnchorPoint=v2(0.5,0)
108
i4.BackgroundColor=bc(364)
109
i4.BackgroundColor3=c3(0.266667,0.266667,0.266667)
110
i4.BorderColor=bc(1003)
111
i4.BorderColor3=c3(0,0,0)
112
i4.BorderSizePixel=0
113
i4.ClipsDescendants=true
114
i4.Position=u2(0.5,0,0,13)
115
i4.Size=u2(1,-30,0,32)
116
i4.Name=rs()
117
i4.Parent=i3
118
i5.AnchorPoint=v2(0.5,0)
119
i5.BackgroundColor=bc(364)
120
i5.BackgroundColor3=c3(0.266667,0.266667,0.266667)
121
i5.BorderColor=bc(1003)
122
i5.BorderColor3=c3(0,0,0)
123
i5.BorderSizePixel=0
124
i5.Position=u2(0.5,0,0,64)
125
i5.Size=u2(1,-30,0,32)
126
i5.Name=rs()
127
i5.Parent=i3
128
i5.Font=e.Font.FredokaOne
129
i5.FontSize=e.FontSize.Size24
130
i5.Text="BRING"
131
i5.TextColor3=c3(0.55,0.55,0.55)
132
i5.TextSize=23
133
i6.Font=e.Font.SourceSans
134
i6.FontSize=e.FontSize.Size14
135
i6.Text="by lulas🍭"
136
i6.TextColor=bc(2)
137
i6.TextColor3=c3(0.635294,0.635294,0.635294)
138
i6.AnchorPoint=v2(1,1)
139
i6.AutomaticSize=e.AutomaticSize.XY
140
i6.BackgroundColor=bc(1001)
141
i6.BackgroundColor3=c3(1,1,1)
142
i6.BackgroundTransparency=1
143
i6.BorderColor=bc(1003)
144
i6.BorderColor3=c3(0,0,0)
145
i6.BorderSizePixel=0
146
i6.Position=u2(1,0,1,0)
147
i6.Name=rs()
148
i6.Parent=i3
149
i7.Font=e.Font.SourceSans
150
i7.FontSize=e.FontSize.Size14
151
i7.Text=""
152
i7.TextColor=bc(2)
153
i7.TextColor3=c3(0.635294,0.635294,0.635294)
154
i7.AnchorPoint=v2(0.5,0)
155
i7.AutomaticSize=e.AutomaticSize.XY
156
i7.BackgroundColor=bc(1001)
157
i7.BackgroundColor3=c3(1,1,1)
158
i7.BackgroundTransparency=1
159
i7.BorderColor=bc(1003)
160
i7.BorderColor3=c3(0,0,0)
161
i7.BorderSizePixel=0
162
i7.Position=u2(0.5,0,0,47)
163
i7.Name=rs()
164
i7.Parent=i3
165
i8.ZIndexBehavior=e.ZIndexBehavior.Sibling
166
i8.Name=rs()
167
168
local function Draggable(window,obj)
169
local MB1enum = e.UserInputType.MouseButton1
170
local TOUCHenum = e.UserInputType.Touch
171
obj = obj or window
172
local activeEntered = 0
173
local mouseStart = nil
174
local dragStart = nil
175
local inputbegancon = nil
176
local rendersteppedcon = nil
177
local inputendedcon = nil
178
local function inputendedf(a)
179
a=a.UserInputType
180
if (a==MB1enum) or (a==TOUCHenum) then
181
rendersteppedcon:Disconnect()
182
inputendedcon:Disconnect()
183
end
184
end
185
local function rendersteppedf()
186
local off = uis:GetMouseLocation()-mouseStart
187
window.Position=dragStart+u2(0,off.X,0,off.Y)
188
end
189
local function inputbeganf(a)
190
a=a.UserInputType
191
if ((a==MB1enum) or (a==TOUCHenum)) and (activeEntered==0) and not uis:GetFocusedTextBox() then
192
mouseStart=uis:GetMouseLocation()
193
dragStart=window.Position
194
if rendersteppedcon then rendersteppedcon:Disconnect() end
195
rendersteppedcon = renderstepped:Connect(rendersteppedf)
196
if inputendedcon then inputendedcon:Disconnect() end
197
inputendedcon = uis.InputEnded:Connect(inputendedf)
198
end
199
end
200
obj.MouseEnter:Connect(function()
201
if inputbegancon then inputbegancon:Disconnect() end
202
inputbegancon = uis.InputBegan:Connect(inputbeganf)
203
end)
204
obj.MouseLeave:Connect(function()
205
inputbegancon:Disconnect()
206
end)
207
local function ondes(d)
208
if d:IsA("GuiObject") then
209
local thisEntered = false
210
local thisAdded = false
211
local con0 = d.MouseEnter:Connect(function()
212
thisEntered = true
213
if (not thisAdded) and d.Active then
214
activeEntered = activeEntered + 1
215
thisAdded = true
216
end
217
end)
218
local con1 = d.MouseLeave:Connect(function()
219
thisEntered = false
220
if thisAdded then
221
activeEntered = activeEntered - 1
222
thisAdded = false
223
end
224
end)
225
local con2 = d:GetPropertyChangedSignal("Active"):Connect(function()
226
if thisEntered then
227
if thisAdded and not d.Active then
228
activeEntered = activeEntered - 1
229
thisAdded = false
230
elseif d.Active and not thisAdded then
231
activeEntered = activeEntered + 1
232
thisAdded = true
233
end
234
end
235
end)
236
local con3 = nil
237
con3 = d.AncestryChanged:Connect(function()
238
if not d:IsDescendantOf(window) then
239
if thisEntered then
240
activeEntered = activeEntered - 1
241
end
242
con0:Disconnect()
243
con1:Disconnect()
244
con2:Disconnect()
245
con3:Disconnect()
246
end
247
end)
248
end
249
end
250
window.DescendantAdded:Connect(ondes)
251
local des=window:GetDescendants()
252
for i=1,#des do
253
ondes(des[i])
254
end
255
end
256
Draggable(i1)
257
258
local others={}
259
for i,v in pairs(plrs:GetPlayers()) do
260
if v~=lp then
261
others[v]=true
262
end
263
end
264
plrs.PlayerAdded:Connect(function(plr)
265
others[plr]=true
266
end)
267
local function findplr(txt)
268
if txt=="" then
269
return nil
270
end
271
for v,_ in pairs(others) do
272
if v.DisplayName==txt then
273
return v
274
end
275
end
276
for v,_ in pairs(others) do
277
if v.Name==txt then
278
return v
279
end
280
end
281
local lower=slower(txt)
282
for v,_ in pairs(others) do
283
if slower(v.DisplayName)==lower then
284
return v
285
end
286
end
287
for v,_ in pairs(others) do
288
if slower(v.Name)==lower then
289
return v
290
end
291
end
292
local l=#txt
293
for v,_ in pairs(others) do
294
if ssub(v.DisplayName,l,l)==txt then
295
return v
296
end
297
end
298
for v,_ in pairs(others) do
299
if ssub(v.Name,l,l)==txt then
300
return v
301
end
302
end
303
for v,_ in pairs(others) do
304
if slower(ssub(v.DisplayName,l,l))==lower then
305
return v
306
end
307
end
308
for v,_ in pairs(others) do
309
if slower(ssub(v.Name,l,l))==lower then
310
return v
311
end
312
end
313
return nil
314
end
315
local target=nil
316
i4:GetPropertyChangedSignal("Text"):Connect(function()
317
local txt=i4.Text
318
target=findplr(txt)
319
if target then
320
if (target.DisplayName) and (target.DisplayName~="") and (target.DisplayName~=target.Name) then
321
i7.Text=target.DisplayName.." @"..target.Name
322
else
323
i7.Text="@"..target.Name
324
end
325
i5.TextColor3=c3(0.301961,1,0)
326
else
327
i7.Text=""
328
i5.TextColor3=c3(0.55,0.55,0.55)
329
end
330
end)
331
plrs.PlayerRemoving:Connect(function(plr)
332
others[plr]=nil
333
if plr==target then
334
target=nil
335
i7.Text=""
336
i5.TextColor3=c3(0.55,0.55,0.55)
337
end
338
end)
339
local notifyid=0
340
local function notify(txt)
341
notifyid=notifyid+1
342
local thisid=notifyid
343
i6.Text=txt
344
twait(2)
345
if notifyid==thisid then
346
i6.Text="by 🍭"
347
end
348
end
349
local bringing=false
350
i5.MouseButton1Click:Connect(function()
351
if bringing then
352
bringing=false
353
i5.Text="BRING"
354
return
355
end
356
if not target then
357
return
358
end
359
local c=lp.Character
360
local c1=target.Character
361
if not (c and c1) then
362
return notify("no xharakter")
363
end
364
if not (c:IsDescendantOf(ws) and c1:IsDescendantOf(ws)) then
365
return notify("character not in workspace")
366
end
367
local hrp=gp(c,"HumanoidRootPart","BasePart")
368
local hrp1=gp(c1,"HumanoidRootPart","BasePart")
369
if not (hrp and hrp1) then
370
return notify("no humanoidrootpart")
371
end
372
bringing=true
373
i5.Text="bringing"
374
local from=hrp1.CFrame
375
local fromP=from.Position
376
local to=hrp.CFrame
377
local toP=to.Position
378
local mag=(fromP-toP).Magnitude-3
379
local lv=cf(fromP,toP).LookVector
380
local vel=0
381
local pos=from.Position-v3_010*2
382
toP=toP-v3_010*2
383
384
local sine=osclock()
385
local lastsine=sine
386
local way=0
387
local reachedmaxspeed=false
388
while bringing and c:IsDescendantOf(ws) and c1:IsDescendantOf(ws) do
389
sine=osclock()
390
local deltaTime=sine-lastsine
391
lastsine=sine
392
if reachedmaxspeed then
393
if mag-way<reachedmaxspeed then
394
vel=vel-deltaTime*speeding
395
if vel<0 then
396
break
397
end
398
end
399
else
400
if way>mag/2 then
401
vel=vel-deltaTime*speeding
402
if vel<0 then
403
break
404
end
405
else
406
vel=vel+deltaTime*speeding
407
if vel>maxspeed then
408
reachedmaxspeed=way
409
vel=maxspeed
410
end
411
end
412
end
413
way=way+vel*deltaTime
414
if not hrp:IsGrounded() then
415
hrp.CFrame=cf(pos+lv*way,toP)*off
416
hrp.Velocity=lv*(vel+1)
417
hrp.RotVelocity=v3_0
418
end
419
twait()
420
end
421
hrp.CFrame=to
422
hrp.Velocity=v3_0
423
hrp.RotVelocity=v3_0
424
bringing=false
425
i5.Text="BRING"
426
end)
427
local iscg,_=pcall(function()
428
i8.Parent=game:FindFirstChildOfClass("CoreGui")
429
end)
430
if not iscg then
431
i8.Parent=lp:FindFirstChildOfClass("PlayerGui")
432
end