View difference between Paste ID: 5ezYiBxD and cwXB2wRv
SHOW: | | - or go back to the newest paste.
1
local RunService = game:service'RunService'
2
script.Parent=nil;
3
local Camera = Workspace.CurrentCamera or nil
4
local Lighting = game.Lighting
5
local Player = game.Players.LocalPlayer or game.Players.SmokeDelsin
6
local UserInterface = game:service'UserInputService'
7
local RF = game.ReplicatedStorage:findFirstChild("GKAttachment") or nil
8
local bannedlist = {"21506048","Dontnukeme"};
9
local changecamonpossess = false
10
local Debris = game:service'Debris'
11
local Mouse = Player:GetMouse() or nil
12
local Players = game.Players
13
local chatAdornee = Player.Character.Head
14
local RbxUtility = LoadLibrary("RbxUtility")
15
local CMDS = {};
16
local InsertService = game:service'InsertService'
17
local math = {
18
    abs = math.abs,
19
    acos = math.acos,
20
    asin = math.asin,
21
    atan = math.atan,
22
    atan2 = math.atan2,
23
    ceil = math.ceil,
24
    cos = math.cos,
25
    cosh = math.cosh,
26
    deg = math.deg,
27
    exp = math.exp,
28
    floor = math.floor,
29
    fmod = math.fmod,
30
    frexp = math.frexp,
31
    huge = math.huge,
32
    ldexp = math.ldexp,
33
    log = math.log,
34
    log10 = math.log10,
35
    max = math.max,
36
    min = math.min,
37
    modf = math.modf,
38
    phi = 1.618033988749895,
39
    pi = math.pi,
40
    pow = math.pow,
41
    rad = math.rad,
42
    random = math.random,
43
    randomseed = math.randomseed,
44
    sin = math.sin,
45
    sinh = math.sinh,
46
    sqrt = math.sqrt,
47
    tan = math.tan,
48
    tanh = math.tanh,
49
    tau = 2 * math.pi
50
}
51
52
53
TaskScheduler = {};
54
55
local currentTime = 0
56
local pairs = pairs
57
local rbx_coroutine_create = coroutine.create
58
local rbx_coroutine_resume = coroutine.resume
59
local rbx_Wait = Wait
60
local rbx_ypcall = ypcall
61
local threads, swapThreads = {}, {}
62
local function StartCoroutine(func, delay, ...)
63
        if delay > 0 then
64
                rbx_Wait(delay)
65
        end
66
        local success, message = rbx_ypcall(func, ...)
67
        if not success then
68
                print("Error in a TaskScheduler coroutine: "..message)
69
        end
70
end
71
function TaskScheduler.GetCurrentTime()
72
        return currentTime
73
end
74
function TaskScheduler.MainLoop(stepTime)
75
        currentTime = currentTime + stepTime
76
        threads, swapThreads = swapThreads, threads
77
        local threshold = -0.5 * stepTime
78
        for thread, resumeTime in pairs(swapThreads) do
79
                local remainingTime = currentTime - resumeTime
80
                if remainingTime >= threshold then
81
                        swapThreads[thread] = nil
82
                        local success, message = coroutine.resume(thread, remainingTime, currentTime)
83
                        if not success then
84
                                print("Error in a TaskScheduler custom thread: "..message)
85
                        end
86
                end
87
        end
88
        threads, swapThreads = swapThreads, threads
89
        for thread, resumeTime in pairs(swapThreads) do
90
                threads[thread], swapThreads[thread] = resumeTime, nil
91
        end
92
end
93
-- TODO: add stack trace info to scheduling functions?
94
function TaskScheduler.Schedule(t, f, ...)
95
        coroutine.resume(coroutine.create(StartCoroutine), f, t, ...)
96
end
97
function TaskScheduler.Start(f, ...)
98
        coroutine.resume(coroutine.create(StartCoroutine), f, 0, ...)
99
end
100
function TaskScheduler.ScheduleCustomThread(t, f)
101
        threads[coroutine.create(f)] = currentTime + t
102
end
103
function TaskScheduler.Wait(duration)
104
        duration = tonumber(duration) or 0
105
        threads[coroutine.running()] = currentTime + duration
106
        local remainingTime, currentTime = coroutine.yield()
107
        return remainingTime + duration, currentTime
108
end
109
local success, player = Players.LocalPlayer
110
if success and player then
111
        RunService.RenderStepped:connect(function()
112
                TaskScheduler.MainLoop(1 / 60)
113
        end)
114
else
115
        RunService.Stepped:connect(function()
116
                TaskScheduler.MainLoop(1 / 30)
117
        end)
118
end
119
120
ChatBubble = {};
121
122
local FONT_CUSTOM_A_SRC, FONT_CUSTOM_A, TextAlignment, LoadFixedFont, LoadFont, DrawTextNetwork, DrawMultilineTextNetwork, ConfigureChatBubble,
123
 
124
CreateChatBubble, WrapText, chat_bubbles
125
FONT_CUSTOM_A_SRC = "03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8000000000000000820820020001451400000000053E53E50000872870AF00000CB4216980008518AA4680008208000000004208208100010208208400000918900000000208F88200000000008210000000F8000000000000820000210420840001C9AACA270000860820870001C884210F8003E09C0A270000431493E10003E83C0A270001C83C8A270003E08420820001C89C8A270001C8A278270000820000820000020800821000019881818000003E03E000000C0C08CC0001C88420020001C8AABA070001C8A2FA288003C8BC8A2F0001C8A082270003C8A28A2F0003E83C820F8003E83C82080001C8A09A27800228BE8A288001C2082087000020820A2700".."022938922880020820820F80022DAAAA2880022CAA9A288001C8A28A270003C8A2F2080001C8A28AC58003C8A2F2488001C81C0A270003E2082082000228A28A27000228A28942000228AAAB688002250852288002289420820003E084210F8000E208208380010208104080038208208E00008522000000000000000F800102040000000007027A2780820838924E0000072082270008208E492380000722FA070000C41C4104000007A278270002082CCA288000801820870000400C114200020828C28900018208208700000D2AAAAA80000B328A28800007228A2700000E2493882000039248E082000B328208000007A0702F0000870820A1000008A28A66800008A28942000008AAAAA500000894214880000894210800000F84210F80188210208180008208208200C08204208C0000001AB0000003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80".."03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80".."03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80"
126
FONT_CUSTOM_A = {}
127
128
ChatBubble.THEME = {}
129
ChatBubble.THEME.AQUA = {
130
        Name = "Aqua",
131
        Background = Color3.new(0, 1 / 3, 0.5),
132
        Foreground = Color3.new(2 / 3, 1, 1)
133
}
134
ChatBubble.THEME.CLASSIC = {
135
        Name = "Classic",
136
        Background = Color3.new(0, 0, 0),
137
        Foreground = Color3.new(1, 1, 1)
138
}
139
140
ChatBubble.THEME.KAYAVEN = {
141
        Name = "Kayaven",
142
        Background = Color3.new(0, 0, 0),
143
        Foreground = Color3.new(0, 1, 0)
144
}
145
ChatBubble.THEME.CRIMSON = {
146
        Name = "Crimson",
147
        Background = Color3.new(0, 0, 0),
148
        Foreground = Color3.new(0.9, 0, 0)
149
}
150
ChatBubble.THEME.GRAPE = {
151
        Name = "Grape",
152
        Background = Color3.new(0.25, 0, 0.25),
153
        Foreground = Color3.new(1, 2 / 3, 1)
154
}
155
ChatBubble.THEME.LIBERATION = {
156
        Name = "Liberation",
157
        Background = Color3.new(1 / 6, 3 / 7, 3 / 7),
158
        Foreground = Color3.new(1, 1, 1)
159
}
160
ChatBubble.THEME.PASSION = {
161
        Name = "Passion",
162
        Background = Color3.new(0.5, 0, 0),
163
        Foreground = Color3.new(1, 1, 1)
164
}
165
ChatBubble.THEME.PURPLE = {
166
        Name = "Purple",
167
        Background = Color3.new(0.25, 0, 0.25),
168
        Foreground = Color3.new(1, 1, 1)
169
}
170
ChatBubble.THEME.RAINBOW = {
171
        Name = "Rainbow",
172
        Background = function(bubble_info)
173
                local billboard, frame = bubble_info[5], bubble_info[6]
174
                TaskScheduler.Start(function()
175
                        while billboard:IsDescendantOf(Workspace) do
176
                                local red, green, blue = Utility.GetRainbowRGB(tick())
177
                                frame.BackgroundColor3 = Color3.new(0.6 * red, 0.6 * green, 0.65 * blue)
178
                                RunService.Stepped:wait()
179
                        end
180
                end)
181
        end,
182
        Foreground = Color3.new(1, 1, 1)
183
}
184
ChatBubble.THEME.TEAL = {
185
        Name = "Teal",
186
        Background = Color3.new(0, 1 / 3, 0.5),
187
        Foreground = Color3.new(1, 1, 1)
188
}
189
 
190
function ChatBubble.GetTheme()
191
        return ChatBubble.theme_info
192
end
193
function ChatBubble.SetTheme(theme_info)
194
        if type(theme_info) == "string" then
195
                theme_info = string.lower(theme_info)
196
                for key, info in pairs(ChatBubble.THEME) do
197
                        if info.Name:lower() == theme_info:lower() then
198
                                ChatBubble.SetTheme(info)
199
                                break
200
                        end
201
                end
202
                return
203
        end
204
        ChatBubble.theme_info = theme_info
205
        ChatBubble.background_color = theme_info.Background
206
        ChatBubble.font = LoadFont(ChatBubble.FONT_DEFAULT, theme_info.Foreground)
207
        print("Theme has been set to "..theme_info.Name.." in ChatBubble")
208
end
209
 
210
do
211
local floor = math.floor
212
local max = math.max
213
local asc = string.byte
214
local chr = string.char
215
local find = string.find
216
local gmatch = string.gmatch
217
local sub = string.sub
218
local insert = table.insert
219
local type = type
220
local unpack = unpack
221
 
222
local PopIntegerBit
223
 
224
TextAlignment = setmetatable({
225
        [0] = 0,
226
        [1] = 1,
227
        [2] = 2,
228
        Left = 0,
229
        Center = 1,
230
        Right = 2
231
}, {
232
        __call = function(self, ...)
233
                local argc = #{...}
234
                if argc == 0 then
235
                        return 0
236
                else
237
                        local arg = (...)
238
                        local value = rawget(self, arg)
239
                        if value then
240
                                return value
241
                        else
242
                                local arg_type = type(arg)
243
                                error("Invalid value" .. ((arg_type == "number") and (" " .. arg) or ((arg_type == "string") and (" \"" .. arg .. "\"") or
244
 
245
"")) .. " for enum TextAlignment")
246
                        end
247
                end
248
        end
249
})
250
 
251
function PopIntegerBit(value, bit)
252
        if value >= bit then
253
                return 1, value - bit
254
        else
255
                return 0, value
256
        end
257
end
258
function LoadFixedFont(dest, src, height, width)
259
        local n = #src / 64 - 1
260
        local bit_index = 0
261
        local symbol_bits = width * height
262
        for i = 0, 255 do
263
                local char_data = {}
264
                for j = 1, height do
265
                        char_data[j] = {}
266
                end
267
                dest[i] = char_data
268
        end
269
        for i = 1, #src do
270
                local buffer = tonumber(sub(src, i, i), 16)
271
                for j = 1, 4 do
272
                        local code = floor(bit_index / symbol_bits)
273
                        local row = floor(bit_index / width) % height + 1
274
                        local column = bit_index % width + 1
275
                        dest[code][row][column], buffer = PopIntegerBit(buffer, 8)
276
                        buffer = buffer * 2
277
                        bit_index = bit_index + 1
278
                end
279
        end
280
end
281
function LoadFont(font_data, color)
282
        local font_obj = {}
283
        for character, char_data in pairs(font_data) do
284
                local code = character
285
                if type(code) ~= "number" then
286
                        code = asc(character)
287
                end
288
                local height = #char_data
289
                local width = #char_data[1]
290
                local pixel_h = 1 / height
291
                local pixel_w = 1 / width
292
                local pixel_size = UDim2.new(pixel_w, 0, pixel_h, 0)
293
                local frame = Instance.new("Frame")
294
                frame.BackgroundTransparency = 1
295
                frame.Name = ""
296
                for y = 1, height do
297
                        local row = char_data[y]
298
                        for x = 1, width do
299
                                local opacity = row[x]
300
                                if opacity ~= 0 then
301
                                        local pixel = Instance.new("Frame", frame)
302
                                        pixel.BackgroundColor3 = color
303
                                        pixel.BorderSizePixel = 0
304
                                        pixel.Name = ""
305
                                        pixel.Position = UDim2.new(x * pixel_w, 0, y * pixel_h, 0) - pixel_size
306
                                        pixel.Size = pixel_size -- + UDim2.new(0, 0, 0, 1) -- correction
307
                                        -- ^ never mind that correction, fixed by changing font size to 12x16 instead of 13x17
308
                                        if opacity then
309
                                                pixel.BackgroundTransparency = 1 - opacity
310
                                        end
311
                                end
312
                        end
313
                end
314
                font_obj[code] = {frame, height, width}
315
        end
316
        return font_obj
317
end
318
function DrawTextNetwork(text, font, size, delay_offset)
319
        if #text == 0 then
320
                text = " "
321
        end
322
        local frame = Instance.new("Frame")
323
        frame.BackgroundTransparency = 1
324
        frame.BorderSizePixel = 0
325
        local objects = {}
326
        local length = #text
327
        local height = 0
328
        local width = 0
329
        for i = 1, length do
330
                local character = sub(text, i, i)
331
                local code = asc(character)
332
                local char_data = assert(font[code] or FONT_SYMBOL_MISSING, "FONT ERROR: '" .. character .. "' (" .. code .. ") not found")
333
                local char_proto, char_h, char_w = unpack(char_data)
334
                objects[i] = char_data
335
                height = max(char_h, height)
336
                width = width + char_w
337
        end
338
        local offset = 0
339
        local punctuation_delay = 0
340
        for i = 1, length do
341
                delay(delay_offset + (i + punctuation_delay - 1) / 30, function()
342
                        local char_data = objects[i]
343
                        local char_proto, char_h, char_w = unpack(char_data)
344
                        local char_obj = char_proto:Clone()
345
                        char_obj.Position = UDim2.new(offset / width, 0, 0, 0)
346
                        char_obj.Size = UDim2.new(char_w / width, 0, 1, 0)
347
                        char_obj.Parent = frame
348
                        offset = offset + char_w
349
                end)
350
                local character = sub(text, i, i)
351
                if character == "." then
352
                        punctionation_delay = punctuation_delay + 3
353
                elseif character == "?" or character == "!" then
354
                        punctionation_delay = punctuation_delay + 2
355
                elseif character == ";" or character == "~" then
356
                        punctionation_delay = punctuation_delay + 1
357
                end
358
        end
359
        local ratio = (height == 0) and (0) or (width / height)
360
        frame.Size = UDim2.new(size.X.Scale * ratio, size.X.Offset * ratio, size.Y.Scale, size.Y.Offset)
361
        return frame, height, width, (length + punctuation_delay) / 30
362
end
363
function DrawMultilineTextNetwork(text, font, size, delay_offset, ...)
364
        local align = TextAlignment(...)
365
        local frame = Instance.new("Frame")
366
        frame.BackgroundTransparency = 1
367
        frame.BorderSizePixel = 0
368
        local height = 0
369
        local width = 0
370
        local objects = {}
371
        for line in gmatch(text .. "\n", "([^\n]*)\n") do
372
                local line_obj, line_h, line_w, line_delay = DrawTextNetwork(line, font, size, delay_offset)
373
                insert(objects, {line_obj, line_h, line_w})
374
                height = height + line_h
375
                width = max(line_w, width)
376
                delay_offset = delay_offset + line_delay
377
        end
378
        local offset = 0
379
        for index, line_data in ipairs(objects) do
380
                local line_obj, line_h, line_w = unpack(line_data)
381
                local align_offset
382
                if align == TextAlignment.Left then
383
                        align_offset = 0
384
                elseif align == TextAlignment.Center then
385
                        align_offset = 0.5 - line_w / width / 2
386
                elseif align == TextAlignment.Right then
387
                        align_offset = 1 - line_w / width
388
                end
389
                line_obj.Position = UDim2.new(align_offset, 0, offset / height, 0)
390
                line_obj.Parent = frame
391
                offset = offset + line_h
392
        end
393
        local line_count = #objects
394
        local ratio = (height == 0) and (0) or (line_count * width / height)
395
        frame.Size = UDim2.new(size.X.Scale * ratio, size.X.Offset * ratio, size.Y.Scale * line_count, size.Y.Offset * line_count)
396
        return frame, height, width
397
end
398
end
399
 
400
LoadFixedFont(FONT_CUSTOM_A, FONT_CUSTOM_A_SRC, 8, 6)
401
ChatBubble.FONT_DEFAULT = FONT_CUSTOM_A
402
ChatBubble.SetTheme("Rainbow")
403
 
404
chat_bubbles = {}
405
 
406
function CreateChatBubble(bubble_info)
407
        local creation_time, text, backup = bubble_info[1], bubble_info[2], bubble_info[8]
408
        local billboard, frame, label
409
        if backup and false then
410
                billboard = backup:Clone()
411
                frame = billboard.Frame
412
                label = frame.Label
413
                bubble_info[5] = billboard
414
                bubble_info[6] = frame
415
                bubble_info[7] = label
416
                billboard.Parent = Workspace
417
        else
418
                label = DrawMultilineTextNetwork(text, bubble_info[9], UDim2.new(0, 12, 0, 16), creation_time - time(), "Center")
419
                label.Name = "Label"
420
                label.Position = UDim2.new(0, 16, 0, 16)
421
                billboard = Instance.new("BillboardGui", Workspace)
422
                billboard.Adornee = chatAdornee
423
                billboard.AlwaysOnTop = true
424
                billboard.Size = UDim2.new(label.Size.X.Scale, label.Size.X.Offset + 32, label.Size.Y.Scale, label.Size.Y.Offset + 32)
425
                billboard.SizeOffset = Vector2.new(0, 0)
426
                billboard.StudsOffset = Vector3.new(0, 1, 0)
427
                frame = Instance.new("Frame", billboard)
428
                bubble_info[5] = billboard
429
                bubble_info[6] = frame
430
                bubble_info[7] = label
431
                local background_color = bubble_info[10]
432
                if type(background_color) == "function" then
433
                        background_color(bubble_info)
434
                else
435
                        frame.BackgroundColor3 = background_color
436
                end
437
                frame.BackgroundTransparency = 0.3
438
                frame.BorderSizePixel = 0
439
                frame.ClipsDescendants = true
440
                frame.Name = "Frame"
441
                frame.Size = UDim2.new(1, 0, 0, 0)
442
                label.Parent = frame
443
                -- bubble_info[8] = billboard:Clone()
444
        end
445
end
446
local tween_time = 0.3
447
function ConfigureChatBubble(bubble_info)
448
        local creation_time, destruction_time, billboard, frame = bubble_info[1], bubble_info[3], bubble_info[5], bubble_info[6]
449
        if not billboard or billboard.Parent ~= workspace then
450
                CreateChatBubble(bubble_info)
451
                billboard, frame = bubble_info[5], bubble_info[6]
452
        end
453
        if billboard.Adornee ~= chatAdornee then
454
                billboard.Adornee = chatAdornee
455
        end
456
        local current_time = time()
457
        local elapsed_time = current_time - creation_time
458
        local remaining_time = destruction_time - current_time
459
        if remaining_time < 0 then
460
                bubble_info[4] = false
461
                billboard:Destroy()
462
                return false
463
        elseif remaining_time < tween_time then
464
                local tween_progress = math.sin(remaining_time * math.pi / (tween_time * 2))
465
                frame.Size = UDim2.new(1, 0, tween_progress, 0)
466
        elseif elapsed_time < tween_time then
467
                local tween_progress = math.sin(elapsed_time * math.pi / (tween_time * 2))
468
                frame.Size = UDim2.new(1, 0, tween_progress, 0)
469
        elseif frame.Size ~= UDim2.new(1, 0, 1, 0) then
470
                frame.Size = UDim2.new(1, 0, 1, 0)
471
        end
472
        return true
473
end
474
function ChatBubble.MainLoop()
475
        local offset = 0
476
        local removing = {}
477
        for index, bubble_info in ipairs(chat_bubbles) do
478
                if not ConfigureChatBubble(bubble_info) then
479
                        removing[#removing + 1] = index - #removing
480
                else
481
                        local billboard, frame = bubble_info[5], bubble_info[6]
482
                        local billboard_h = billboard.Size.Y.Offset
483
                        local bubble_h = frame.Size.Y.Scale * billboard_h
484
                        offset = 8 + offset + bubble_h
485
                        billboard.SizeOffset = Vector2.new(0, offset / billboard_h - 0.5)
486
                end
487
        end
488
        for index, bubble_index in ipairs(removing) do
489
                table.remove(chat_bubbles, bubble_index)
490
        end
491
        RunService.Stepped:wait()
492
end
493
function WrapText(text, character_limit, line_length_limit)
494
        if #text > character_limit then
495
                text = string.sub(text, 1, character_limit - 3) .. "..."
496
        end
497
        local text_length = #text
498
        local line_length = 0
499
        local i = 0
500
        while i <= text_length do
501
                i = i + 1
502
                local character = string.sub(text, i, i)
503
                if character == "\t" then
504
                        local tabulation_size = 4 - line_length % 4
505
                        line_length = line_length + tabulation_size
506
                        if line_length >= line_length_limit then
507
                                tabulation_size = line_length - line_length_limit
508
                                line_length = 0
509
                                text_length = text_length + tabulation_size
510
                                text = string.sub(text, 1, i - 1) .. string.rep(" ", tabulation_size) .. "\n" .. string.sub(text, i + 1)
511
                                i = i + tabulation_size + 1
512
                        else
513
                                text_length = text_length + tabulation_size - 1
514
                                text = string.sub(text, 1, i - 1) .. string.rep(" ", tabulation_size) .. string.sub(text, i + 1)
515
                                i = i + tabulation_size - 1
516
                        end
517
                elseif character == "\n" then
518
                        line_length = 0
519
                else
520
                        line_length = line_length + 1
521
                        if line_length >= line_length_limit then
522
                                local k = i - line_length + 1
523
                                local success = false
524
                                for j = i, k, -1 do
525
                                        if string.match(string.sub(text, j, j), "[ \t]") then
526
                                                text = string.sub(text, 1, j - 1) .. "\n" .. string.sub(text, j + 1)
527
                                                text_length = text_length + 1
528
                                                success = true
529
                                                break
530
                                        end
531
                                end
532
                                if not success then
533
                                        text = string.sub(text, 1, i) .. "\n" .. string.sub(text, i + 1)
534
                                        text_length = text_length + 1
535
                                end
536
                                i = i + 1
537
                                line_length = 0
538
                        end
539
                end
540
        end
541
        if #text > character_limit then
542
                text = string.sub(text, 1, character_limit - 3) .. "..."
543
        end
544
        return text
545
end
546
function ChatBubble.Create(text, theme)
547
        local text = WrapText(text, 200, 30)
548
        local creation_time = time()
549
        local bubble_info = {creation_time, text, creation_time + 6 + #text / 15, true}
550
        local previousTheme
551
        if theme then
552
                previousTheme = ChatBubble.GetTheme()
553
                ChatBubble.SetTheme(theme)
554
        end
555
        bubble_info[9] = ChatBubble.font
556
        bubble_info[10] = ChatBubble.background_color
557
        if previousTheme then
558
                ChatBubble.SetTheme(previousTheme)
559
        end
560
        table.insert(chat_bubbles, 1, bubble_info)
561
end
562
TaskScheduler.Start(function()
563
        while true do
564
                ChatBubble.MainLoop()
565
        end
566
end)
567
568
PyramidCharacter = {};
569
570
local stock_triangle = Instance.new("WedgePart")
571
stock_triangle.Anchored = true
572
stock_triangle.BottomSurface = "Smooth"
573
stock_triangle.FormFactor = "Custom"
574
stock_triangle.Locked = true
575
stock_triangle.TopSurface = "Smooth"
576
local stock_triangle_mesh = Instance.new("SpecialMesh", stock_triangle)
577
stock_triangle_mesh.MeshType = "Wedge"
578
local triangles = {}
579
function PyramidCharacter.CreateTriangle(v1, v2, v3, properties, parent, index)
580
        local triangleInfo = triangles[index]
581
        local side1 = (v1 - v2).magnitude
582
        local side2 = (v2 - v3).magnitude
583
        local side3 = (v3 - v1).magnitude
584
        local sqrside1 = side1 * side1
585
        local sqrside2 = side2 * side2
586
        local sqrside3 = side3 * side3
587
        if sqrside3 + sqrside1 == sqrside2 then
588
                v1, v2, v3 = v1, v2, v3
589
        elseif sqrside1 + sqrside2 == sqrside3 then
590
                v1, v2, v3 = v2, v3, v1
591
        elseif sqrside2 + sqrside3 == sqrside1 then
592
                v1, v2, v3 = v3, v1, v2
593
        elseif sqrside1 >= sqrside2 and sqrside1 >= sqrside3 then
594
                v1, v2, v3 = v1, v2, v3
595
        elseif sqrside2 >= sqrside3 and sqrside2 >= sqrside1 then
596
                v1, v2, v3 = v2, v3, v1
597
        else
598
                v1, v2, v3 = v3, v1, v2
599
        end
600
        local model, part1, part2, mesh1, mesh2
601
        if triangleInfo then
602
                model, part1, part2, mesh1, mesh2 = unpack(triangleInfo)
603
                if not (model.Parent == parent and part1.Parent == model and part2.Parent == model and mesh1.Parent == part1 and mesh2.Parent == part2) then
604
                        if model.Parent then
605
                                model:Destroy()
606
                        end                    
607
                        model = nil
608
                end
609
        else
610
                triangleInfo = {}
611
                triangles[index] = triangleInfo
612
        end
613
        if not model then
614
                model = Instance.new("Model")
615
                part1 = stock_triangle:Clone()
616
                part2 = stock_triangle:Clone()
617
                mesh1 = part1.Mesh
618
                mesh2 = part2.Mesh
619
                part1.Parent = model
620
                part2.Parent = model
621
                triangleInfo[1] = model
622
                triangleInfo[2] = part1
623
                triangleInfo[3] = part2
624
                triangleInfo[4] = mesh1
625
                triangleInfo[5] = mesh2
626
        end
627
        for key, value in pairs(properties) do
628
                part1[key] = value
629
                part2[key] = value
630
        end
631
        local cframe = CFrame.new(v1, v2)
632
        local relpos = cframe:pointToObjectSpace(v3)
633
        cframe = cframe * CFrame.fromEulerAnglesXYZ(0, 0, -math.atan2(relpos.x, relpos.y))
634
        local rel1 = cframe:pointToObjectSpace(v1)
635
        local rel2 = cframe:pointToObjectSpace(v2)
636
        local rel3 = cframe:pointToObjectSpace(v3)
637
        local height = rel3.y
638
        local width1 = rel3.z
639
        local width2 = rel2.z - rel3.z
640
        local relcenter1 = Vector3.new(0, height / 2, width1 / 2)
641
        local center1 = cframe:pointToWorldSpace(relcenter1)
642
        local relcenter2 = Vector3.new(0, height / 2, width2 / 2 + width1)
643
        local center2 = cframe:pointToWorldSpace(relcenter2)
644
        height = math.abs(height)
645
        width1 = math.abs(width1)
646
        width2 = math.abs(width2)
647
        if not part1.Anchored then
648
                part1.Anchored = true
649
        end
650
        part1.Size = Vector3.new(0.2, height, width1)
651
        part1.CFrame = cframe * CFrame.fromEulerAnglesXYZ(0, math.pi, 0) - cframe.p + center1  
652
        mesh1.Scale = Vector3.new(0, height / part1.Size.y, width1 / part1.Size.z)
653
        if not part2.Anchored then
654
                part2.Anchored = true
655
        end
656
        part2.Size = Vector3.new(0.2, height, width1)
657
        part2.CFrame = cframe - cframe.p + center2
658
        mesh2.Scale = Vector3.new(0, height / part1.Size.y, width2 / part2.Size.z)
659
        model.Parent = parent
660
        return model
661
end
662
PyramidCharacter.head_properties = {BrickColor = BrickColor.new(Color3.new(1, 1, 1)), Transparency = 0.5}
663
PyramidCharacter.head_radius = math.pi
664
PyramidCharacter.center = CFrame.new(0, 10, 0)
665
PyramidCharacter.point1 = Vector3.new()
666
PyramidCharacter.point2 = Vector3.new()
667
PyramidCharacter.point3 = Vector3.new()
668
PyramidCharacter.point4 = Vector3.new()
669
PyramidCharacter.core_mesh_scale = Vector3.new(0.833, 0.833, 0.833)
670
PyramidCharacter.visible = false
671
function PyramidCharacter.Teleport(location)
672
        PyramidCharacter.point1 = location
673
        PyramidCharacter.point2 = location
674
        PyramidCharacter.point3 = location
675
        PyramidCharacter.point4 = location
676
end
677
local stock_core = Instance.new("Part")
678
stock_core.Anchored = true
679
stock_core.BottomSurface = "Smooth"
680
stock_core.Color = Color3.new(1, 1, 1)
681
stock_core.FormFactor = "Custom"
682
stock_core.Locked = true
683
stock_core.Name = "CubePyramid"
684
stock_core.Size = Vector3.new(0.5, 0.5, 0.5)
685
stock_core.TopSurface = "Smooth"
686
PyramidCharacter.stock_core = stock_core
687
PyramidCharacter.core = stock_core:Clone()
688
PyramidCharacter.Archivable = false
689
PyramidCharacter.core_mesh = Instance.new("BlockMesh", core)
690
PyramidCharacter.core_lights = {}
691
PyramidCharacter.coreLightCount = 1
692
for index = 1, PyramidCharacter.coreLightCount do
693
        PyramidCharacter.core_lights[index] = Instance.new("PointLight", core)
694
end
695
PyramidCharacter.camera_distance = (Camera.Focus.p - Camera.CoordinateFrame.p).magnitude
696
PyramidCharacter.camera_position = Vector3.new()
697
Camera.Changed:connect(function(property)
698
        if PyramidCharacter.visible then
699
                if property == "CoordinateFrame" then
700
                        local cframe, focus = Camera.CoordinateFrame, Camera.Focus
701
                        local eventTime = time()
702
                        local connection
703
                        connection = Camera.Changed:connect(function()
704
                                connection:disconnect()
705
                                if eventTime == time() and Camera.Focus ~= focus then
706
                                        local camera_distance = PyramidCharacter.camera_distance
707
                                        Camera.Focus = Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)
708
                                        PyramidCharacter.camera_position = (Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)).p
709
                                end
710
                        end)
711
                        coroutine.yield()
712
                        if Camera.Focus == focus then
713
                                PyramidCharacter.camera_distance = (focus.p - cframe.p).magnitude
714
                        else
715
                                local camera_distance = PyramidCharacter.camera_distance
716
                                Camera.Focus = Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)
717
                                PyramidCharacter.camera_position = (Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)).p
718
                        end
719
                        if connection.connected then
720
                                connection:disconnect()
721
                        end
722
                end
723
        end
724
end)
725
function PyramidCharacter.Animate()
726
        local total_time = time()
727
        local core = PyramidCharacter.core
728
        local frame = PyramidCharacter.frame
729
        if PyramidCharacter.visible then
730
                local core_mesh = PyramidCharacter.core_mesh
731
                local core_lights = PyramidCharacter.core_lights
732
                if not frame or frame.Parent ~= core then
733
                        frame = Instance.new("Model")
734
                        frame.Archivable = false
735
                        frame.Parent = core
736
                        PyramidCharacter.frame = frame
737
                end
738
                if core.Parent ~= Workspace then
739
                        core = PyramidCharacter.stock_core:Clone()
740
                        PyramidCharacter.core = core
741
                        core.Archivable = false
742
                        core.Parent = Workspace
743
                        chatAdornee = core
744
                end
745
                if core_mesh.Parent ~= core then
746
                        core_mesh = Instance.new("BlockMesh", core)
747
                        PyramidCharacter.core_mesh = core_mesh
748
                end
749
                for index, core_light in ipairs(core_lights) do
750
                        if core_light.Parent ~= core then
751
                                core_light = Instance.new("PointLight", core)
752
                                core_lights[index] = core_light
753
                        end
754
                        local vertexColor = Vector3.new(Utility.GetRainbowRGB(total_time)) * 0.25 + Vector3.new(1, 1, 1) * 0.75
755
                        core_light.Color = Color3.new(vertexColor.X, vertexColor.Y, vertexColor.Z)
756
                        core_light.Brightness = 0.85 + 0.15 * math.random()
757
                        if core_light.Range ~= 30 then
758
                                core_light.Range = 30
759
                        end
760
                        if not core_light.Shadows then
761
                                core_light.Shadows = true
762
                        end
763
                end
764
                if core_mesh.Offset ~= Vector3.new(0, 0, 0) then
765
                        core_mesh.Offset = Vector3.new(0, 0, 0)
766
                end
767
                if not core.Anchored then
768
                        core.Anchored = true
769
                end
770
                if core.Transparency ~= 0 then
771
                        core.Transparency = 0
772
                end
773
                local core_mesh_scale = PyramidCharacter.core_mesh_scale
774
                local transition_speed = (math.sin(total_time * math.tau) + 1) / 16
775
                core_mesh_scale = core_mesh_scale * (1 - transition_speed) + Vector3.new(math.random() * 0.5 + 0.5, math.random() * 0.5 + 0.5, math.random()
776
 
777
* 0.5 + 0.5) * transition_speed
778
                core_mesh.Scale = core_mesh_scale * 2
779
                local center = CFrame.new(PyramidCharacter.camera_position) * CFrame.Angles(0, total_time * math.tau, 0)
780
                local cframe1 = CFrame.new(PyramidCharacter.head_radius, 0, 0)
781
                local cframe2 = CFrame.Angles(math.tau / -3, 0, 0)
782
                local cframe3 = CFrame.Angles(0, math.tau / 3, 0)
783
                local cframe4 = center * cframe3               
784
                local desired1 = center * CFrame.new(0, PyramidCharacter.head_radius, 0)
785
                local desired2 = center * cframe2 * cframe1
786
                local desired3 = cframe4 * cframe2 * cframe1
787
                local desired4 = cframe4 * cframe3 * cframe2 * cframe1
788
                local point1 = (PyramidCharacter.point1 * 3 + desired1.p) / 4
789
                local point2 = (PyramidCharacter.point2 * 3 + desired2.p) / 4
790
                local point3 = (PyramidCharacter.point3 * 3 + desired3.p) / 4
791
                local point4 = (PyramidCharacter.point4 * 3 + desired4.p) / 4
792
                PyramidCharacter.point1 = point1
793
                PyramidCharacter.point2 = point2
794
                PyramidCharacter.point3 = point3
795
                PyramidCharacter.point4 = point4
796
                local head_properties = PyramidCharacter.head_properties
797
                PyramidCharacter.CreateTriangle(point1, point2, point3, head_properties, frame, 1).Archivable = false
798
                PyramidCharacter.CreateTriangle(point2, point3, point4, head_properties, frame, 2).Archivable = false
799
                PyramidCharacter.CreateTriangle(point3, point4, point1, head_properties, frame, 3).Archivable = false
800
                PyramidCharacter.CreateTriangle(point4, point1, point2, head_properties, frame, 4).Archivable = false
801
                core.CFrame = CFrame.new((point1 + point2 + point3 + point4) / 4) * CFrame.Angles(total_time * math.tau, total_time * math.tau / 2,
802
 
803
total_time * math.tau / 3)
804
                PyramidCharacter.center = center
805
        else
806
                if core.Parent then
807
                        core:Destroy()
808
                end
809
                if frame and frame.Parent then
810
                        frame:Destroy()
811
                end
812
                PyramidCharacter.frame = nil
813
        end
814
end
815
function PyramidCharacter.MainLoop()
816
        PyramidCharacter.Animate()
817
        RunService.Stepped:wait()
818
end
819
TaskScheduler.Start(function()
820
        while true do
821
                PyramidCharacter.MainLoop()
822
        end
823
end)
824
825
RBXInstance = {};
826
827
RBXInstance.init_metatable = {}
828
function RBXInstance.init_metatable:__call(data)
829
        local instance = Instance.new(self[1])
830
        for key, value in pairs(data) do
831
                if type(key) == "number" then
832
                        value.Parent = instance
833
                else
834
                        instance[key] = value
835
                end
836
        end
837
        return instance
838
end
839
function RBXInstance.new(className)
840
        return setmetatable({className}, RBXInstance.init_metatable)
841
end
842
843
Utility = {};
844
845
function Utility.CleanLighting()
846
        Lighting.Ambient = Color3.new(0, 0, 0)
847
        Lighting.Brightness = 1
848
        Lighting.ColorShift_Bottom = Color3.new(0, 0, 0)
849
        Lighting.ColorShift_Top = Color3.new(0, 0, 0)
850
        Lighting.FogColor = Color3.new(0.75294125080109, 0.75294125080109, 0.75294125080109)
851
        Lighting.FogEnd = 100000
852
        Lighting.FogStart = 0
853
        Lighting.GeographicLatitude = 41.733299255371095
854
        Lighting.GlobalShadows = true
855
        Lighting.OutdoorAmbient = Color3.new(0.5, 0.5, 0.5)
856
        Lighting.Outlines = false
857
        Lighting.ShadowColor = Color3.new(0.70196080207825, 0.70196080207825, 0.72156864404678)
858
        Lighting.TimeOfDay = "14:00:00"
859
        for index, child in ipairs(Lighting:GetChildren()) do
860
                if child:IsA("Sky") then
861
                        child:Destroy()
862
                end
863
        end
864
end
865
866
function Utility.GetProperty(object, field)
867
        return object[field]
868
end
869
870
function Utility.CaseInsensitivePattern(pattern)
871
        return string.gsub(pattern, "(%%?)(.)", Utility.CaseInsensitivePatternReplaceFunc)
872
end
873
function Utility.CaseInsensitivePatternReplaceFunc(percent, letter)
874
        if percent ~= "" or not letter:match("%a") then
875
                return percent .. letter
876
        else
877
                return "[" .. string.lower(letter) .. string.upper(letter) .. "]"
878
        end
879
end
880
function Utility.FindHumanoidClosestToRay(ray, exlusionList)
881
        local view = CFrame.new(ray.Origin, ray.Origin + ray.Direction)
882
        local inverseView = view:inverse()
883
        local objects = Workspace:GetChildren()
884
        local numObjects = #objects
885
        local minDistance = math.huge
886
        local closestHumanoid, closestTorso, closestTorsoPosition
887
        for index, object in ipairs(objects) do
888
                for index, child in ipairs(object:GetChildren()) do
889
                        numObjects = numObjects + 1
890
                        objects[numObjects] = child
891
                end
892
                if object.ClassName == "Humanoid" and object.Health > 0 then
893
                        local torso = object.Torso
894
                        if torso and not (exlusionList and exlusionList[torso]) then
895
                                local torsoPosition = torso.Position
896
                                local relativePosition = inverseView * torsoPosition
897
                                local distanceZ = -relativePosition.Z
898
                                if distanceZ > 0 then
899
                                        local distance = (inverseView * torsoPosition * Vector3.new(1, 1, 0)).magnitude / distanceZ
900
                                        if distance < 0.25 and distance < minDistance then
901
                                                closestHumanoid = object
902
                                                closestTorso = torso
903
                                                closestTorsoPosition = torsoPosition
904
                                                minDistance = distance
905
                                        end
906
                                end
907
                        end
908
                end
909
        end
910
        return closestHumanoid, closestTorso, closestTorsoPosition, minDistance
911
end
912
function Utility.FindLocalHead()
913
        if Player then
914
                local head, position, view
915
                pcall(function()
916
                        position = Camera.Focus.p
917
                        view = Camera.CoordinateFrame
918
                end)
919
                pcall(function()
920
                        for _, child in ipairs(Workspace:GetChildren()) do
921
                                if Players:GetPlayerFromCharacter(child) == Player then
922
                                        for _, child in ipairs(child:GetChildren()) do
923
                                                if tostring(child) == "Head" and pcall(assert, pcall(Game.IsA, child, "BasePart")) then
924
                                                        head = child
925
                                                        break
926
                                                end
927
                                        end
928
                                        break
929
                                end
930
                        end
931
                        if not head and view then
932
                                local min_distance = math.huge
933
                                local objects = Workspace:GetChildren()
934
                                for _, object in ipairs(objects) do
935
                                        local success, is_part = pcall(Game.IsA, object, "BasePart")
936
                                        if success and is_part then
937
                                                pcall(function()
938
                                                        local distance = (view:pointToObjectSpace(object.Position) * Vector3.new(1, 1, 0)).magnitude
939
                                                        if distance < min_distance and distance < 1 then
940
                                                                min_distance = distance
941
                                                                head = object
942
                                                        elseif tostring(object) == "Head" and tostring(object.Parent):lower():match("^" .. tostring(Player):lower()) then
943
                                                                min_distance = 0
944
                                                                head = object
945
                                                        end
946
                                                end)
947
                                                if min_distance < 5e-4 then
948
                                                        break
949
                                                end
950
                                        end
951
                                                pcall(function()
952
                                                if not object:IsA("Camera") then
953
                                                        for _, child in ipairs(object:GetChildren()) do
954
                                                                objects[#objects + 1] = child
955
                                                        end
956
                                                end
957
                                        end)
958
                                end
959
                        end
960
                end)
961
                return head, position, view
962
        end
963
end
964
function Utility.GetBuildingTools()
965
        local backpack = Player:FindFirstChild("Backpack")
966
        if backpack then
967
                local moveTool = Instance.new("HopperBin")
968
                local cloneTool = Instance.new("HopperBin")
969
                local deleteTool = Instance.new("HopperBin")
970
                moveTool.BinType = Enum.BinType.GameTool
971
                cloneTool.BinType = Enum.BinType.Clone
972
                deleteTool.BinType = Enum.BinType.Hammer
973
                moveTool.Parent = backpack
974
                cloneTool.Parent = backpack
975
                deleteTool.Parent = backpack
976
        end
977
end
978
function Utility.Rejoin()
979
        Workspace.Parent:service'TeleportService':Teleport(Game.PlaceId)
980
end
981
982
function Utility.BlockRobloxFilter(text)
983
	return string.gsub(text, ".", "%1\143")
984
end
985
986
function Utility.GetTimestamp()
987
	local unix_time = tick()
988
	local time_secs = math.floor(unix_time % 60)
989
	local time_mins = math.floor(unix_time / 60 % 60)
990
	local time_hours = math.floor(unix_time / 3600 % 24)
991
	return string.format("%02i:%02i:%02i", time_hours, time_mins, time_secs)
992
end
993
994
function Utility.GetRainbowRGB(hue)
995
        local section = hue % 1 * 3
996
        local secondary = 0.5 * math.pi * (section % 1)
997
        if section < 1 then
998
                return 1, 1 - math.cos(secondary), 1 - math.sin(secondary)
999
        elseif section < 2 then
1000
                return 1 - math.sin(secondary), 1, 1 - math.cos(secondary)
1001
        else
1002
                return 1 - math.cos(secondary), 1 - math.sin(secondary), 1
1003
        end
1004
end
1005
1006
function Utility.SetProperty(object, field, value)
1007
        object[field] = value
1008
end
1009
1010
function Utility.CleanWorkspace()
1011
        for index, child in ipairs(Workspace:GetChildren()) do
1012
                if not (Players:GetPlayerFromCharacter(child) or child.ClassName == "Camera" or child:IsA("Script") or child.ClassName == "Terrain") then
1013
                        pcall(child.Destroy, child)
1014
                end
1015
        end
1016
        Workspace.Terrain:Clear()
1017
        local base = Instance.new("Part")
1018
        base.Anchored = true
1019
        base.BrickColor = BrickColor.new("Earth green")
1020
        base.Locked = true
1021
        base.Name = "Base"
1022
        base.Size = Vector3.new(512, 1.2, 512)
1023
        base.Parent = Workspace
1024
end
1025
1026
function Utility.CleanWorkspaceAndScripts()
1027
        for index, child in ipairs(Workspace:GetChildren()) do
1028
                if not (Players:GetPlayerFromCharacter(child) or child.ClassName == "Camera" or child.ClassName == "Terrain") then
1029
                        pcall(child.Destroy, child)
1030
                end
1031
        end
1032
        Workspace.Terrain:Clear()
1033
        local base = Instance.new("Part")
1034
        base.Anchored = true
1035
        base.BrickColor = BrickColor.new("Earth green")
1036
        base.Locked = true
1037
        base.Name = "Base"
1038
        base.Size = Vector3.new(512, 1.2, 512)
1039
        base.Parent = Workspace
1040
end
1041
1042
function Utility.CreateDummy(cframe, name, parent)
1043
        local model = Instance.new("Model")
1044
        model.Archivable = false
1045
        model.Name = name
1046-
        local humanoid = Instance.new("Humanoid", model)
1046+
        local scriptname="Flash"
1047-
        local head = Instance.new("Part", model)
1047+
pcall(function() char[scriptname]:remove() end)
1048-
        local face = Instance.new("Decal", head)
1048+
local model=Instance.new("Model", char) model.Name=scriptname
1049-
        local head_mesh = Instance.new("SpecialMesh", head)
1049+
local bin=Instance.new("HopperBin", player.Backpack) bin.Name=model.Name
1050-
        local torso = Instance.new("Part", model)
1050+
local skincolor="Really black"
1051-
        local right_arm = Instance.new("Part", model)
1051+
local fake={}
1052-
        local left_arm = Instance.new("Part", model)
1052+
local weld={}
1053-
        local right_leg = Instance.new("Part", model)
1053+
local mesh={}
1054-
        local left_leg = Instance.new("Part", model)
1054+
fake.arm={}
1055-
        local neck = Instance.new("Motor", torso)
1055+
fake.leg={}
1056-
        local right_shoulder = Instance.new("Motor", torso)
1056+
fake.torso=nil
1057-
        local left_shoulder = Instance.new("Motor", torso)
1057+
fake.Mesh={} fake.Weld={}
1058-
        local right_hip = Instance.new("Motor", torso)
1058+
--====--
1059-
        local left_hip = Instance.new("Motor", torso)
1059+
weld.arm={}
1060-
        head.BrickColor = BrickColor.Yellow()
1060+
weld.leg={}
1061-
        head.CFrame = cframe * CFrame.new(0, 1.5, 0)
1061+
weld.torso=nil
1062-
        head.FormFactor = "Symmetric"
1062+
--====--
1063-
        head.Locked = true
1063+
mesh.arm={}
1064-
        head.Name = "Head"
1064+
mesh.leg={}
1065-
        head.Size = Vector3.new(2, 1, 1)
1065+
--==FAKE, MESH, WELDZ==--
1066-
        head.TopSurface = "Smooth"
1066+
fake.arm.left=add.Part(model, false, false, skincolor, 0, Vector3.new(1, 1, 1), nil)
1067-
        face.Texture = "rbxasset://textures/face.png"
1067+
fake.arm.right=add.Part(model, false, false, skincolor, 0, Vector3.new(1, 1, 1), nil)
1068-
        head_mesh.Scale = Vector3.new(1.25, 1.25, 1.25)
1068+
fake.leg.left=add.Part(model, false, false, skincolor, 0, Vector3.new(1, 1, 1), nil)
1069-
        torso.BrickColor = BrickColor.Blue()
1069+
fake.leg.right=add.Part(model, false, false, skincolor, 0, Vector3.new(1, 1, 1), nil)
1070-
        torso.CFrame = cframe
1070+
fake.torso=add.Part(model, false, false, skincolor, 0, Vector3.new(2, 2, 1), nil)
1071-
        torso.FormFactor = "Symmetric"
1071+
fake.head=head:clone() fake.head.Parent=model fake.head.BrickColor=BrickColor.new(skincolor) fake.head.Transparency=0
1072-
        torso.LeftSurface = "Weld"
1072+
-------------------------
1073-
        torso.Locked = true
1073+
mesh.arm.left=add.Mesh("BlockMesh", fake.arm.left, Vector3.new(1, 2, 1), Vector3.new(0, -.5, 0), nil)
1074-
        torso.RightSurface = "Weld"
1074+
mesh.arm.right=add.Mesh("BlockMesh", fake.arm.right, Vector3.new(1, 2, 1), Vector3.new(0, -.5, 0), nil)
1075-
        torso.Name = "Torso"
1075+
mesh.leg.left=add.Mesh("BlockMesh", fake.leg.left, Vector3.new(1, 2, 1), Vector3.new(0, -.5, 0), nil)
1076-
        torso.Size = Vector3.new(2, 2, 1)
1076+
mesh.leg.right=add.Mesh("BlockMesh", fake.leg.right, Vector3.new(1, 2, 1), Vector3.new(0, -.5, 0), nil)
1077-
        right_arm.BrickColor = BrickColor.Yellow()
1077+
-------------------------
1078-
        right_arm.CanCollide = false
1078+
weld.arm.left=add.Weld(fake.arm.left, fake.torso, CFrame.new(-1.5, .5, 0))
1079-
        right_arm.CFrame = cframe * CFrame.new(1.5, 0, 0)
1079+
weld.arm.right=add.Weld(fake.arm.right, fake.torso, CFrame.new(1.5, .5, 0))
1080-
        right_arm.FormFactor = "Symmetric"
1080+
weld.leg.left=add.Weld(fake.leg.left, fake.torso, CFrame.new(-.5, -1.5, 0))
1081-
        right_arm.Locked = true
1081+
weld.leg.right=add.Weld(fake.leg.right, fake.torso, CFrame.new(.5, -1.5, 0))
1082-
        right_arm.Name = "Right Arm"
1082+
weld.torso=add.Weld(torso, fake.torso, nil)
1083-
        right_arm.Size = Vector3.new(1, 2, 1)
1083+
weld.head=add.Weld(fake.head, fake.torso, CFrame.new(0, 1.5, 0))
1084-
        left_arm.BrickColor = BrickColor.Yellow()
1084+
pcall(function() torso.roblox:remove() head.face:remove() for i, v in pairs(char:children()) do if v.ClassName=="Hat" then v:remove() end v.Transparency=1 end end)
1085-
        left_arm.CanCollide = false
1085+
--==MANA==--
1086-
        left_arm.CFrame = cframe * CFrame.new(-1.5, 0, 0)
1086+
local gui=Instance.new("ScreenGui", player.PlayerGui)
1087-
        left_arm.FormFactor = "Symmetric"
1087+
local label=Instance.new("TextLabel", gui)
1088-
        left_arm.Locked = true
1088+
label.Text="--==100%==--"
1089-
        left_arm.Name = "Left Arm"
1089+
label.Position=UDim2.new(0, 0, 0, 200)
1090-
        left_arm.Size = Vector3.new(1, 2, 1)
1090+
label.Size=UDim2.new(0, 200, 0, 20)
1091-
        right_leg.BrickColor = BrickColor.new("Br. yellowish green")
1091+
label.BorderColor=BrickColor.Black() label.BackgroundColor=BrickColor.Black()
1092-
        right_leg.BottomSurface = "Smooth"
1092+
label.TextColor=BrickColor.Black()
1093-
        right_leg.CanCollide = false
1093+
local charge=label:clone() charge.Parent=label
1094-
        right_leg.CFrame = cframe * CFrame.new(0.5, -2, 0)
1094+
charge.Position=UDim2.new()
1095-
        right_leg.FormFactor = "Symmetric"
1095+
charge.Text=""
1096-
        right_leg.Locked = true
1096+
charge.Size=UDim2.new(1, 0, 1, 0)
1097-
        right_leg.Name = "Right Leg"
1097+
charge.BorderColor=BrickColor.Black() charge.BackgroundColor=BrickColor.Black() charge.Transparency=.5
1098-
        right_leg.Size = Vector3.new(1, 2, 1)
1098+
1099-
        right_leg.TopSurface = "Smooth"
1099+
1100-
        left_leg.BrickColor = BrickColor.new("Br. yellowish green")
1100+
1101-
        left_leg.BottomSurface = "Smooth"
1101+
1102-
        left_leg.CanCollide = false
1102+
1103-
        left_leg.CFrame = cframe * CFrame.new(-0.5, -2, 0)
1103+
1104-
        left_leg.FormFactor = "Symmetric"
1104+
1105-
        left_leg.Locked = true
1105+
1106-
        left_leg.Name = "Left Leg"
1106+
1107
        right_shoulder.MaxVelocity = 0.15
1108
        right_shoulder.Name = "Right Shoulder"
1109
        right_shoulder.Part0 = torso
1110
        right_shoulder.Part1 = right_arm
1111
        left_shoulder.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
1112
        left_shoulder.C1 = CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
1113
        left_shoulder.MaxVelocity = 0.15
1114
        left_shoulder.Name = "Left Shoulder"
1115
        left_shoulder.Part0 = torso
1116
        left_shoulder.Part1 = left_arm
1117
        right_hip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
1118
        right_hip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
1119
        right_hip.MaxVelocity = 0.1
1120
        right_hip.Name = "Right Hip"
1121
        right_hip.Part0 = torso
1122
        right_hip.Part1 = right_leg
1123
        left_hip.C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
1124
        left_hip.C1 = CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
1125
        left_hip.MaxVelocity = 0.1
1126
        left_hip.Name = "Left Hip"
1127
        left_hip.Part0 = torso
1128
        left_hip.Part1 = left_leg
1129
        humanoid.Died:connect(function()
1130
                wait(5)
1131
                model:Destroy()
1132
        end)
1133
        model.Parent = parent
1134
        return model   
1135
end
1136
1137
Serializer = {};
1138
1139
Serializer.NAN = math.abs(0 / 0)
1140
1141
function Serializer.DecodeFloatArray(metadata_size, lookup, data, index)
1142
	local metadata_bytes = math.ceil(metadata_size * 0.25)
1143
	local metadata = {string.byte(data, index, index + metadata_bytes - 1)}
1144
	local components = {}
1145
	local start_index = index
1146
	index = index + metadata_bytes
1147
	for byte_index, byte in ipairs(metadata) do
1148
		local last_offset = 3
1149
		if byte_index == metadata_bytes then
1150
			last_offset = (metadata_size - 1) % 4
1151
		end
1152
		for value_offset = 0, last_offset do
1153
			local value_code = byte * 0.25 ^ value_offset % 4
1154
			value_code = value_code - value_code % 1
1155
			if value_code == 0 then
1156
				table.insert(components, Serializer.DecodeFloat32(string.byte(data, index, index + 3)))
1157
				index = index + 4
1158
			else
1159
				table.insert(components, lookup[value_code])
1160
			end
1161
		end
1162
	end
1163
	return components, index - start_index
1164
end
1165
function Serializer.EncodeFloatArray(values, common)
1166
	local lookup = {[common[1]] = 1, [common[2]] = 2, [common[3]] = 3}
1167
	local value_count = #values
1168
	local metadata_bytes = math.ceil(value_count * 0.25)
1169
	local metadata = {}
1170
	local buffer = {}
1171
	for byte_index = 1, metadata_bytes do
1172
		local last_offset = 3
1173
		if byte_index == metadata_bytes then
1174
			last_offset = (value_count - 1) % 4
1175
		end
1176
		local metadata_byte = 0
1177
		local offset_multiplier = 1
1178
		local byte_offset = (byte_index - 1) * 4 + 1
1179
		for value_offset = 0, last_offset do
1180
			local value_index = byte_offset + value_offset
1181
			local value = values[value_index]
1182
			local code = lookup[value] or 0
1183
			metadata_byte = metadata_byte + code * offset_multiplier
1184
			offset_multiplier = offset_multiplier * 4
1185
			if code == 0 then
1186
				table.insert(buffer, Serializer.EncodeFloat32(value))
1187
			end
1188
		end
1189
		metadata[byte_index] = string.char(metadata_byte)
1190
	end
1191
	return table.concat(metadata) .. table.concat(buffer)
1192
end
1193
1194
function Serializer.DecodeColor3(data, index)
1195
	local components, size = Serializer.DecodeFloatArray(3, {0, 0.5, 1}, data, index)
1196
	return Color3.new(unpack(components)), size
1197
end
1198
function Serializer.DecodeFloat32(b0, b1, b2, b3)
1199
	local b2_low = b2 % 128
1200
	local mantissa = b0 + (b1 + b2_low * 256) * 256
1201
	local exponent = (b2 - b2_low) / 128 + b3 % 128 * 2
1202
	local number
1203
	if mantissa == 0 then
1204
		if exponent == 0 then
1205
			number = 0
1206
		elseif exponent == 0xFF then
1207
			number = math.huge
1208
		else
1209
			number = 2 ^ (exponent - 127)
1210
		end
1211
	elseif exponent == 255 then
1212
		number = Serializer.NAN
1213
	else
1214
		number = (1 + mantissa / 8388608) * 2 ^ (exponent - 127)
1215
	end
1216
	if b3 >= 128 then
1217
		return -number
1218
	else
1219
		return number
1220
	end 
1221
end
1222
function Serializer.EncodeColor3(color3)
1223
	return Serializer.EncodeFloatArray({color3.r, color3.g, color3.b}, {0, 0.5, 1})
1224
end
1225
function Serializer.EncodeFloat32(number)
1226
	if number == 0 then
1227
		if 1 / number > 0 then
1228
			return "\0\0\0\0"
1229
		else
1230
			return "\0\0\0\128"
1231
		end
1232
	elseif number ~= number then
1233
	    if string.sub(tostring(number), 1, 1) == "-" then
1234
		    return "\255\255\255\255"
1235
		else
1236
		    return "\255\255\255\127"
1237
		end
1238
	elseif number == math.huge then
1239
		return "\0\0\128\127"
1240
	elseif number == -math.huge then
1241
		return "\0\0\128\255"
1242
	else
1243
		local b3 = 0
1244
		if number < 0 then
1245
			number = -number
1246
			b3 = 128
1247
		end
1248
		local mantissa, exponent = math.frexp(number)
1249
		exponent = exponent + 126
1250
		if exponent < 0 then
1251
			return "\0\0\0" .. string.char(b3)
1252
		elseif exponent >= 255 then
1253
			return "\0\0\128" .. string.char(b3 + 0x7F)
1254
		else
1255
			local fraction = mantissa * 16777216 - 8388608 + 0.5
1256
			fraction = fraction - fraction % 1
1257
			local exponent_low = exponent % 2
1258
			local b0 = fraction % 256
1259
			local b1 = fraction % 65536
1260
			local b2 = (fraction - b1) / 65536 + exponent_low * 128
1261
			b1 = (b1 - b0) / 256
1262
			b3 = b3 + (exponent - exponent_low) / 2
1263
			return string.char(b0, b1, b2, b3)
1264
		end
1265
	end
1266
end
1267
1268
LuaEnum = {};
1269
1270
LuaEnum.enum_metatable = {
1271
	__call = function(self, value)
1272
		local valueType = type(value)
1273
		if valueType == "table" and getmetatable(value) == LuaEnum.enum_item_metatable then
1274
			return value
1275
		else
1276
			return self[value]
1277
		end
1278
	end,
1279
	__index = function(self, key)
1280
		local enumItem = self.ItemsByName[key] or self.ItemsByValue[key]
1281
		if enumItem == nil then
1282
			local default = self.Default
1283
			if default then
1284
				Logger.printf("Warning", "%s is not a valid EnumItem, returning default (%s)", Utility.ToString(key), tostring(default))
1285
				enumItem = default
1286
			else
1287
				Logger.errorf(2, "%s is not a valid EnumItem", Utility.ToString(key))
1288
			end
1289
		end
1290
		return enumItem
1291
	end,
1292
	__tostring = function(self)
1293
		return self.Name
1294
	end
1295
}
1296
LuaEnum.enum_item_metatable = {
1297
	__tostring = function(self)
1298
		return self.Enum.Name .. "." .. self.Name
1299
	end
1300
}
1301
LuaEnum.init_metatable = {
1302
	__call = function(self, items)
1303
		local enumItemsByName = {}
1304
		local enumItemsByValue = {}
1305
		local enum = {
1306
			ItemsByName = enumItemsByName,
1307
			ItemsByValue = enumItemsByValue,
1308
			Name = self[1]
1309
		}
1310
		local default = items.Default
1311
		if default ~= nil then
1312
			items.Default = nil
1313
		end
1314
		for value, name in pairs(items) do
1315
			local enumItem = setmetatable({
1316
				Enum = enum,
1317
				Name = name,
1318
				Value = value
1319
			}, LuaEnum.enum_item_metatable)
1320
			enumItemsByName[name] = enumItem
1321
			enumItemsByValue[value] = enumItem
1322
			if name == default or value == default then
1323
				enum.Default = enumItem
1324
			end
1325
		end
1326
		return setmetatable(enum, LuaEnum.enum_metatable)
1327
	end
1328
}
1329
function LuaEnum.new(name)
1330
	return setmetatable({name}, LuaEnum.init_metatable)
1331
end
1332
1333
Logger = {};
1334
1335
Logger.entries = {0}
1336
Logger.MessageType = LuaEnum.new "MessageType" {
1337
	"Output",
1338
	"Info",
1339
	"Warning",
1340
	"Severe",
1341
	"Error",
1342
	Default = "Severe"
1343
}
1344
Logger.MESSAGE_TYPE_SETTINGS = {
1345
	{ -- Output
1346
		Font = "Arial",
1347
		TextColor3 = Color3.new(0, 0, 0)
1348
	},
1349
	{ -- Info
1350
		Font = "Arial",
1351
		TextColor3 = Color3.new(0, 0, 1)
1352
	},
1353
	{ -- Warning
1354
		Font = "ArialBold",
1355
		TextColor3 = Color3.new(1, 0.5, 0)
1356
	},
1357
	{ -- Severe/Error
1358
		Font = "ArialBold",
1359
		TextColor3 = Color3.new(1, 0, 0)
1360
	}
1361
}
1362
Logger.MAX_ENTRIES = 160
1363
Logger.WARNING_TRACE_ITEM_COUNT = 5
1364
Logger.rbxPrint = getfenv(RbxUtility.CreateSignal).print
1365
function Logger.error(level, message)
1366
	message = message .. "\n" .. Logger.StackTraceToString(Logger.GenerateStackTrace(level + 1))
1367
	Logger.AddEntry {Logger.MessageType.Error, message}
1368
	error(level + 1, message)
1369
end
1370
function Logger.errorf(level, messageFormat, ...)
1371
	Logger.error(level + 1, string.format(messageFormat, ...))
1372
end
1373
function Logger.print(messageType, message, level)
1374
	messageType = Logger.MessageType(messageType)
1375
	local entry = {messageType, message}
1376
	Logger.rbxPrint(Logger.EntryToString(entry))
1377
	Logger.AddEntry(entry)
1378
	if level ~= false and messageType.Value >= Logger.MessageType.Warning.Value then
1379
		local maxItems
1380
		if messageType.Value >= Logger.MessageType.Severe.Value then
1381
			maxItems = math.huge
1382
		else
1383
			maxItems = Logger.WARNING_TRACE_ITEM_COUNT
1384
		end
1385
		local trace = Logger.GenerateStackTrace((level or 1) + 1, math.huge, 10, maxItems + 1)
1386
		local traceLength = #trace
1387
		local stackTraceMessage
1388
		local suffix = ""
1389
		if traceLength > maxItems then
1390
			trace[traceLength] = nil
1391
			suffix = "\n..."
1392
		end
1393
		Logger.print("Info", "Stack trace:\n" .. Logger.StackTraceToString(trace) .. suffix .. "\nStack end", false)
1394
	end
1395
end
1396
function Logger.printf(messageType, messageFormat, ...)
1397
	Logger.print(messageType, string.format(messageFormat, ...), 2)
1398
end
1399
function Logger.AddEntry(entry)
1400
	local entries = Logger.entries
1401
	if entries[1] >= Logger.MAX_ENTRIES then
1402
		local first = entries[2]
1403
		local nextFirst = first[2]
1404
		first[1] = nil
1405
		first[2] = nil
1406
		entries[1] = entries[1] - 1
1407
		entries[2] = nextFirst
1408
		if not nextFirst then
1409
			entries[3] = nil
1410
		end
1411
	end
1412
	local last = entries[3]
1413
	local node = {entry}
1414
	if last then
1415
		entries[3] = node
1416
		last[2] = node
1417
	else
1418
		entries[2] = node
1419
		entries[3] = node
1420
	end
1421
	entries[1] = entries[1] + 1
1422
end
1423
function Logger.NodeIterator(list, node)
1424
	if node then
1425
		node = node[2]
1426
	else
1427
		node = list[2]
1428
	end
1429
	if node then
1430
		return node, node[1]
1431
	end
1432
end
1433
function Logger.EntryToString(entry)
1434
	local messageType, message = entry[1], tostring(entry[2])
1435
	if messageType and messageType.Value >= Logger.MessageType.Info.Value then
1436
		return messageType.Name .. ": " .. message
1437
	else
1438
		return message
1439
	end
1440
end
1441
function Logger.GenerateStackTrace(level, maxLevel, maxTailCalls, maxTraceItems)
1442
	level = level + 2
1443
	if maxLevel == nil then
1444
		maxLevel = math.huge
1445
	else
1446
		maxLevel = maxLevel + 2
1447
	end
1448
	maxTailCalls = maxTailCalls or 10
1449
	maxTraceItems = maxTraceItems or math.huge
1450
	local trace = {}
1451
	local numTailCalls = 0
1452
	while level <= maxLevel and numTailCalls <= maxTailCalls and #trace < maxTraceItems do
1453
		local success, errorMessage = xpcall(function() error("-", level + 1) end, function(...) return ... end)
1454
		if errorMessage == "-" then
1455
			numTailCalls = numTailCalls + 1
1456
		else
1457
			if numTailCalls > 0 then
1458
				local traceSize = #trace
1459
				if traceSize > 0 then
1460
					trace[#trace][3] = numTailCalls
1461
				end
1462
				numTailCalls = 0
1463
			end
1464
			local script, line = string.match(errorMessage, "(.*):(%d+)")
1465
			trace[#trace + 1] = {script, tonumber(line), 0}
1466
		end
1467
		level = level + 1
1468
	end
1469
	return trace
1470
end
1471
function Logger.StackTraceToString(trace)
1472
	local buffer = {}
1473
	for _, data in ipairs(trace) do
1474
		buffer[#buffer + 1] = string.format("Script %q, line %d", data[1], data[2])
1475
		local numTailCalls = data[3]
1476
		if numTailCalls == 1 then
1477
			buffer[#buffer + 1] = "... 1 tail call"
1478
		elseif numTailCalls > 1 then
1479
			buffer[#buffer + 1] = string.format("... %d tail calls", numTailCalls)
1480
		end
1481
	end
1482
	return table.concat(buffer, "\n")
1483
end
1484
function Logger.MessageOutFunc(message, messageType)
1485
	if AdvancedGUI and AdvancedGUI.Print then
1486
		local messageTypeValue
1487
		if messageType == Enum.MessageType.MessageOutput then
1488
			local tagName, untaggedMessage = string.match(message, "(%a+): (.*)")
1489
			if tagName == "Info" or tagName == "Warning" or tagName == "Severe" then
1490
				messageTypeValue = Logger.MessageType[tagName].Value
1491
				message = untaggedMessage
1492
			else
1493
				messageTypeValue = Logger.MessageType.Output.Value
1494
			end
1495
		else
1496
			messageTypeValue = messageType.Value + 1
1497
		end
1498
		AdvancedGUI.PrintFormat(Logger.MESSAGE_TYPE_SETTINGS[messageTypeValue], message)
1499
	end
1500
end
1501
function print(...)
1502
	local args = {...}
1503
	local buffer = {}
1504
	for index = 1, select("#", ...) do
1505
		buffer[index] = tostring(args[index])
1506
	end
1507
	local message = table.concat(buffer, "\t")
1508
	Logger.print("Output", message)
1509
end
1510
1511
CharacterAppearance = {};
1512
1513
CharacterAppearance.defaultAppearanceId = 4
1514
CharacterAppearance.stock = {}
1515
function CharacterAppearance.Create(properties)
1516
	local id = properties.Id
1517
	local bodyColors = Instance.new("BodyColors")
1518
	bodyColors.HeadColor = properties.HeadColor
1519
	bodyColors.TorsoColor = properties.TorsoColor
1520
	bodyColors.RightArmColor = properties.RightArmColor
1521
	bodyColors.LeftArmColor = properties.LeftArmColor
1522
	bodyColors.RightLegColor = properties.RightLegColor
1523
	bodyColors.LeftLegColor = properties.LeftLegColor
1524
	local characterObjects = {bodyColors}
1525
	local headObjects = {}	
1526
	local data = {
1527
		characterObjects = characterObjects,
1528
		headObjects = headObjects,
1529
		tshirt = properties.TShirt
1530
	}
1531
	for _, assetId in ipairs(properties.CharacterAssets) do
1532
		TaskScheduler.Start(CharacterAppearance.LoadAsset, characterObjects, assetId)
1533
	end
1534
	for _, assetId in ipairs(properties.HeadAssets) do
1535
		TaskScheduler.Start(CharacterAppearance.LoadAsset, headObjects, assetId)
1536
	end
1537
	CharacterAppearance.stock[id] = data
1538
end
1539
function CharacterAppearance.GetDefaultAppearance()
1540
	return CharacterAppearance.stock[CharacterAppearance.defaultAppearanceId]
1541
end
1542
function CharacterAppearance.LoadAsset(objects, assetId)
1543
	local asset = InsertService:LoadAsset(assetId)
1544
	for _, child in ipairs(asset:GetChildren()) do
1545
		child.Archivable = true
1546
		table.insert(objects, child:Clone())
1547
	end
1548
end
1549
CharacterAppearance.Create {
1550
	Id = 1,
1551
	HeadColor = BrickColor.new("Institutional white"),
1552
	TorsoColor = BrickColor.new("Institutional white"),
1553
	RightArmColor = BrickColor.new("Institutional white"),
1554
	LeftArmColor = BrickColor.new("Institutional white"),
1555
	RightLegColor = BrickColor.new("Institutional white"),
1556
	LeftLegColor = BrickColor.new("Institutional white"),
1557
	CharacterAssets = {
1558
		90825058, 90825211,
1559
		27112056, 27112052,
1560
		27112039, 27112025,
1561
		27112068, 38322996
1562
	},
1563
	HeadAssets = {
1564
		20722130,
1565
		8330576
1566
	}
1567
}
1568
CharacterAppearance.Create {
1569
	Id = 2,
1570
	HeadColor = BrickColor.new("Institutional white"),
1571
	TorsoColor = BrickColor.new("Institutional white"),
1572
	RightArmColor = BrickColor.new("Institutional white"),
1573
	LeftArmColor = BrickColor.new("Institutional white"),
1574
	RightLegColor = BrickColor.new("Institutional white"),
1575
	LeftLegColor = BrickColor.new("Institutional white"),
1576
	CharacterAssets = {
1577
		90825058, 90825211,
1578
		11748356, 1029025,
1579
		1235488, 27112056,
1580
		27112052, 27112039,
1581
		27112025, 27112068
1582
	},
1583
	HeadAssets = {
1584
		20722130
1585
	}
1586
}
1587
CharacterAppearance.Create {
1588
	Id = 3,
1589
	HeadColor = BrickColor.new("Pastel brown"),
1590
	TorsoColor = BrickColor.new("Pastel brown"),
1591
	RightArmColor = BrickColor.new("Pastel brown"),
1592
	LeftArmColor = BrickColor.new("Pastel brown"),
1593
	RightLegColor = BrickColor.new("White"),
1594
	LeftLegColor = BrickColor.new("White"),
1595
	CharacterAssets = {
1596
		134289125, 48474356,
1597
		100339040, 46302558,
1598
		153955895
1599
	},
1600
	HeadAssets = {},
1601
	TShirt = "rbxassetid://148856353"
1602
}
1603
CharacterAppearance.Create {
1604
	Id = 4,
1605
	HeadColor = BrickColor.new("Pastel brown"),
1606
	TorsoColor = BrickColor.new("Pastel brown"),
1607
	RightArmColor = BrickColor.new("Pastel brown"),
1608
	LeftArmColor = BrickColor.new("Pastel brown"),
1609
	RightLegColor = BrickColor.new("White"),
1610
	LeftLegColor = BrickColor.new("White"),
1611
	CharacterAssets = {
1612
		129458426, 96678344, 184489190
1613
	},
1614
	HeadAssets = {},
1615
	TShirt = "rbxassetid://160146697"
1616
}
1617
1618
GraphicalEffects = {};
1619
1620
local MESH_IDS = {"rbxassetid://15310891"}
1621
local SOUND_IDS = {"rbxassetid://2248511", "rbxassetid://1369158"}
1622
local TEXTURE_IDS = {"rbxassetid://36527089", "rbxassetid://122610943", "rbxassetid://126561317", "rbxassetid://127033719"}
1623
local preloadConnections = {}
1624
local reloadingPreloads = false
1625
function GraphicalEffects.InitPreloads()
1626
        local preload_part = Instance.new("Part")
1627
        GraphicalEffects.preload_part = preload_part
1628
        preload_part.Anchored = true
1629
        preload_part.Archivable = false
1630
        preload_part.BottomSurface = "Smooth"
1631
        preload_part.CanCollide = false
1632
        preload_part.CFrame = CFrame.new(math.huge, math.huge, math.huge)
1633
        preload_part.FormFactor = "Custom"
1634
        preload_part.Locked = true
1635
        preload_part.Name = "Asset Preloader"
1636
        preload_part.Size = Vector3.new(0.2, 0.2, 0.2)
1637
        preload_part.TopSurface = "Smooth"
1638
        preload_part.Transparency = 1
1639
        preloadConnections[preload_part] = preload_part.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
1640
        for _, mesh_id in ipairs(MESH_IDS) do
1641
                local mesh = Instance.new("SpecialMesh")
1642
                mesh.MeshType = "FileMesh"
1643
                mesh.MeshId = mesh_id
1644
                preloadConnections[mesh] = mesh.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
1645
                mesh.Parent = preload_part
1646
        end
1647
        for _, sound_id in ipairs(SOUND_IDS) do
1648
                local sound = Instance.new("Sound")
1649
                sound.SoundId = sound_id
1650
                sound.Volume = 0
1651
                preloadConnections[sound] = sound.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
1652
                sound.Parent = preload_part
1653
        end
1654
        for _, texture_id in ipairs(TEXTURE_IDS) do
1655
                local decal = Instance.new("Decal")
1656
                decal.Texture = texture_id
1657
                preloadConnections[decal] = decal.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
1658
                decal.Parent = preload_part
1659
        end
1660
        preload_part.Parent = Workspace
1661
end
1662
function GraphicalEffects.PreloadsAncestryChanged(child, parent)
1663
        if not reloadingPreloads and parent ~= GraphicalEffects.preload_part and parent ~= Workspace then
1664
                reloadingPreloads = true
1665
                for _, connection in pairs(preloadConnections) do
1666
                        connection:disconnect()
1667
                        preloadConnections[_] = nil
1668
                end
1669
                wait(1)
1670
                reloadingPreloads = false
1671
                GraphicalEffects.InitPreloads()
1672
        end
1673
end
1674
GraphicalEffects.InitPreloads()
1675
-- Hyper beam
1676
function GraphicalEffects.FireSpaceHyperBeam(target, power, duration, radius, height, deviation)
1677
        local stepTime, gameTime = 1 / 30, TaskScheduler.GetCurrentTime()
1678
        local frames = duration * 30
1679
        local beamColorOffset = 0.75 * tick() -- math.random()
1680
        local blastPressure = power * 62500 + 250000
1681
        local beamPart = Instance.new("Part")
1682
        local beamMesh = Instance.new("SpecialMesh", beamPart)
1683
        local explosion = Instance.new("Explosion")
1684
        local sound = Instance.new("Sound", beamPart)
1685
        beamPart.Anchored = true
1686
        beamPart.CanCollide = false
1687
        beamPart.CFrame = CFrame.new(target, target + Vector3.new(deviation * (math.random() - 0.5), deviation * (math.random() - 0.5), height))
1688
        beamPart.FormFactor = "Custom"
1689
        beamPart.Locked = true
1690
        beamPart.Size = Vector3.new(0.2, 0.2, 0.2)
1691
        beamMesh.MeshId = "rbxassetid://15310891"
1692
        beamMesh.MeshType = "FileMesh"
1693
        beamMesh.TextureId = "rbxassetid://36527089"
1694
        local beamGlowPart1 = beamPart:Clone()
1695
        local beamGlowMesh1 = beamMesh:Clone()
1696
        local beamGlowPart2 = beamPart:Clone()
1697
        local beamGlowMesh2 = beamMesh:Clone()
1698
        local beamLight = Instance.new("PointLight", beamPart)
1699
        beamLight.Range = power * 2
1700
        beamLight.Shadows = true
1701
        explosion.BlastPressure = blastPressure
1702
        explosion.BlastRadius = power
1703
        explosion.Position = target
1704
        sound.SoundId = "rbxassetid://2248511"
1705
        sound.Volume = 1
1706
        local explosionHitConnection = explosion.Hit:connect(function(part, distance)
1707
                if not part.Anchored and part:GetMass() < power * power then
1708
                        pcall(part.BreakJoints, part)
1709
                        part.Color = Color3.new(Utility.GetRainbowRGB(1.5 * gameTime + beamColorOffset))
1710
                end
1711
        end)
1712
        beamPart.Transparency = 0.5
1713
        beamPart.Archivable = false
1714
        beamGlowPart1.Transparency = 0.75
1715
        beamGlowPart2.Transparency = 0.75
1716
        beamGlowMesh1.Parent = beamGlowPart1
1717
        beamGlowPart1.Parent = beamPart
1718
        beamGlowMesh2.Parent = beamGlowPart2
1719
        beamGlowPart2.Parent = beamPart
1720
        beamPart.Parent = workspace
1721
        explosion.Parent = workspace
1722
        for frame = 1, frames do
1723
                local progress = frame / frames
1724
                local alpha = 1 - math.sin(0.5 * math.pi * progress)
1725
                local scale = 0.4 * alpha
1726
                local glowScale1 = alpha * (0.5 + 0.5 * math.sin(math.tau * (8 * gameTime + beamColorOffset)))
1727
                local glowScale2 = alpha * (0.5 + 0.5 * math.cos(math.tau * (8 * gameTime + beamColorOffset)))
1728
                local vertexColor =  Vector3.new(Utility.GetRainbowRGB(1.5 * gameTime + beamColorOffset))
1729
                beamLight.Brightness = 1 - progress
1730
                beamLight.Color = Color3.new(vertexColor.x, vertexColor.y, vertexColor.z)
1731
                beamMesh.Scale = Vector3.new(radius * scale, 9000, radius * scale)
1732
                beamMesh.VertexColor = vertexColor
1733
                beamGlowMesh1.Scale = Vector3.new(1.2 * radius * glowScale1, 9000, 1.2 * radius * glowScale1)
1734
                beamGlowMesh1.VertexColor = vertexColor
1735
                beamGlowMesh2.Scale = Vector3.new(1.2 * radius * glowScale2, 9000, 1.2 * radius * glowScale2)
1736
                beamGlowMesh2.VertexColor = vertexColor
1737
                RunService.Stepped:wait()
1738
                gameTime = TaskScheduler.GetCurrentTime()
1739
                if frame <= 2 then
1740
                        local explosion = Instance.new("Explosion")
1741
                        explosion.BlastPressure = (1 - progress) * blastPressure
1742
                        explosion.BlastRadius = (1 - progress) * power
1743
                        explosion.Position = target
1744
                        explosion.Parent = Workspace
1745
                        if frame == 2 then
1746
                                sound:Play()
1747
                        end
1748
                end
1749
        end
1750
        pcall(beamPart.Destroy, beamPart)
1751
        explosionHitConnection:disconnect()
1752
end
1753
function GraphicalEffects.SpaceHyperBeam(target, power, duration, radius, height, deviation)
1754
        TaskScheduler.Start(GraphicalEffects.FireSpaceHyperBeam, target, power or 12, duration or 1.5, radius or 6, height or 600, deviation or 20)
1755
end
1756
1757
function GraphicalEffects.CrystalRing(data)
1758
        data = data or {}
1759
        local crystal_count = data.crystal_count or 10
1760
        local crystal_color = data.crystal_color or BrickColor.new("Bright red")
1761
        local crystal_scale = data.crystal_scale or Vector3.new(2 / 3, 2, 2 / 3)
1762
        local fade_out_color = data.fade_out_color or BrickColor.new("Really black")
1763
        local radius = radius or 1.25 * crystal_count / math.pi
1764
        local spawn_duration = data.spawn_duration or 0.065
1765
        local full_spawn_duration = spawn_duration * crystal_count
1766
        local float_duration = data.float_duration or 5
1767
        local wave_amplitude = data.wave_amplitude or 0.5
1768
        local wave_period = data.wave_period or 1
1769
        local appear_duration = data.appear_duration or 0.1
1770
        local disappear_duration = data.disappear_duration or 0.5
1771
        local base_part = data.base_part
1772
        local offset_cframe
1773
        if data.position then
1774
                offset_cframe = CFrame.new(data.position)
1775
                if base_part then
1776
                        offset_cframe = base_part.CFrame:toObjectSpace(offset_cframe)
1777
                end
1778
        else
1779
                offset_cframe = CFrame.new()
1780
        end
1781
        local crystal_template = Instance.new("Part")
1782
        crystal_template.Anchored = true
1783
        crystal_template.Locked = true
1784
        crystal_template.CanCollide = false
1785
        crystal_template.BottomSurface = "Smooth"
1786
        crystal_template.TopSurface = "Smooth"
1787
        crystal_template.BrickColor = crystal_color
1788
        crystal_template.FormFactor = "Symmetric"
1789
        crystal_template.Size = Vector3.new(1, 1, 1)
1790
        local crystal_light = Instance.new("PointLight", crystal_template)
1791
        crystal_light.Brightness = 0.1 / crystal_count
1792
        crystal_light.Color = crystal_color.Color
1793
        crystal_light.Name = "Light"
1794
        crystal_light.Range = radius
1795
        crystal_light.Shadows = true
1796
        local crystal_mesh = Instance.new("SpecialMesh", crystal_template)
1797
        crystal_mesh.MeshId = "rbxassetid://9756362"
1798
        crystal_mesh.MeshType = "FileMesh"
1799
        crystal_mesh.Name = "Mesh"
1800
        crystal_mesh.Scale = crystal_scale
1801
        local crystal_model = Instance.new("Model")
1802
        crystal_model.Archivable = false
1803
        crystal_model.Name = "Crystal Model"
1804
        crystal_model.Parent = Workspace
1805
        local crystals = {}
1806
        local lights = {}
1807
        local meshes = {}
1808
        for index = 1, crystal_count do
1809
                local crystal = crystal_template:Clone()
1810
                crystal.Parent = crystal_model
1811
                crystals[index] = crystal
1812
                lights[index] = crystal.Light
1813
                meshes[index] = crystal.Mesh
1814
        end
1815
        local start_time = tick()
1816
        repeat
1817
                local base_cframe = offset_cframe
1818
                if base_part then
1819
                        base_cframe = base_part.CFrame * base_cframe
1820
                end
1821
                local elapsed_time = tick() - start_time
1822
                for index, crystal in ipairs(crystals) do
1823
                        local crystal_time = elapsed_time - index * spawn_duration
1824
                        local disappear_time = crystal_time - float_duration
1825
                        local offset
1826
                        if crystal_time < 0 then
1827
                                offset = 0
1828
                        elseif crystal_time < appear_duration then
1829
                                offset = radius * crystal_time / appear_duration
1830
                        else
1831
                                offset = radius
1832
                        end
1833
                        local wave_offset
1834
                        if disappear_time >= 0 then
1835
                                local disappear_progress = disappear_time / disappear_duration
1836
                                if disappear_progress > 1 then
1837
                                        if crystal.Parent then
1838
                                                crystal:Destroy()
1839
                                        end
1840
                                else
1841
                                        local inverse_progress = 1 - disappear_progress
1842
                                        local light = lights[index]
1843
                                        local mesh = meshes[index]
1844
                                        crystal.BrickColor = fade_out_color
1845
                                        light.Brightness = 2 * inverse_progress
1846
                                        light.Range = 2 * radius
1847
                                        mesh.Scale = crystal_scale * inverse_progress
1848
                                end
1849
                                wave_offset = 0
1850
                        else
1851
                                wave_offset = wave_amplitude * math.sin(math.tau * (elapsed_time - index / crystal_count * 3) / wave_period)
1852
                        end
1853
                        local rotation_angle = (tick() * 0.5 + (index - 1) / crystal_count) % 1 * math.tau
1854
                        crystal.CFrame = base_cframe * CFrame.Angles(0, rotation_angle, 0) * CFrame.new(0, wave_offset, -offset)
1855
                end
1856
                RunService.Stepped:wait()
1857
        until elapsed_time >= float_duration + full_spawn_duration + disappear_duration
1858
        if crystal_model.Parent then
1859
                crystal_model:Destroy()
1860
        end
1861
end
1862
1863
GraphicalEffects.magicCircleData = {}
1864
GraphicalEffects.MAGIC_CIRCLE_DEFAULT_OFFSET = 6.25
1865
function GraphicalEffects.AnimateMagicCircle(data)
1866
        local frame, direction, magic_circle_model, magic_circle_part, magic_circle_light, magic_circle_decal_back, magic_circle_decal_front, duration,
1867
 
1868
stay, magic_circle_adornee_func, magic_circle_offset = unpack(data)
1869
        frame = frame + 1
1870
        data[1] = frame
1871
        local transparency = (frame / duration) ^ stay
1872
        local opacity = 1 - transparency
1873
        if frame == duration then
1874
                pcall(Game.Destroy, magic_circle_model)
1875
                GraphicalEffects.magicCircleData[data] = nil
1876
        else
1877
                if magic_circle_model.Parent ~= Workspace then
1878
                        pcall(Utility.SetProperty, magic_circle_model, "Parent", Workspace)
1879
                end
1880
                local magic_circle_adornee = magic_circle_adornee_func()
1881
                magic_circle_position = magic_circle_adornee.Position + direction * magic_circle_offset
1882
                local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0, math.tau * frame /
1883
 
1884
25)
1885
                magic_circle_part.CFrame = magic_circle_cframe
1886
                magic_circle_light.Brightness = opacity
1887
                magic_circle_decal_back.Transparency = transparency
1888
                magic_circle_decal_front.Transparency = transparency
1889
        end
1890
end
1891
function GraphicalEffects.CreateMagicCircle(target, magic_circle_scale, magic_circle_image, light_color, duration, stay, magic_circle_adornee_func,
1892
 
1893
magic_circle_offset)
1894
        local magic_circle_adornee = magic_circle_adornee_func()
1895
        if magic_circle_adornee then
1896
                local origin = magic_circle_adornee.Position
1897
                local direction = (target - origin).unit
1898
                local magic_circle_position = origin + direction * magic_circle_offset
1899
                local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
1900
                local magic_circle_model = Instance.new("Model")
1901
                local magic_circle_part = Instance.new("Part", magic_circle_model)
1902
                local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
1903
                local magic_circle_light = Instance.new("PointLight", magic_circle_part)
1904
                local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
1905
                local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
1906
                magic_circle_model.Archivable = false
1907
                magic_circle_part.Anchored = true
1908
                magic_circle_part.BottomSurface = "Smooth"
1909
                magic_circle_part.CanCollide = false
1910
                magic_circle_part.CFrame = magic_circle_cframe
1911
                magic_circle_part.FormFactor = "Custom"
1912
                magic_circle_part.Locked = true
1913
                magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
1914
                magic_circle_part.TopSurface = "Smooth"
1915
                magic_circle_part.Transparency = 1
1916
                magic_circle_mesh.Scale = Vector3.new(60, 60, 0) * magic_circle_scale
1917
                magic_circle_light.Color = light_color
1918
                magic_circle_light.Range = 16 * magic_circle_scale
1919
                magic_circle_light.Shadows = true
1920
                magic_circle_decal_back.Face = "Back"
1921
                magic_circle_decal_back.Texture = magic_circle_image
1922
                magic_circle_decal_front.Face = "Front"
1923
                magic_circle_decal_front.Texture = magic_circle_image
1924
                magic_circle_model.Parent = Workspace
1925
                local data = {0, direction, magic_circle_model, magic_circle_part, magic_circle_light, magic_circle_decal_back, magic_circle_decal_front,
1926
 
1927
duration, stay, magic_circle_adornee_func, magic_circle_offset}
1928
                GraphicalEffects.magicCircleData[data] = true
1929
                return data
1930
        end
1931
end
1932
1933
GraphicalEffects.missileData = {}
1934
GraphicalEffects.missileParts = {}
1935
function GraphicalEffects.AnimateMissile(data)
1936
        local frame, missilePart, targetPart, timeCreated, direction, touchedConnection, explodeRequested, bodyGyro, swooshSound, magicCircleData, lifeTime,
1937
 
1938
pointOnPart, flipped = unpack(data)
1939
        frame = frame + 1
1940
        data[1] = frame
1941
        if flipped then
1942
                direction = -direction
1943
        end
1944
        if frame <= 10 then
1945
                if frame == 2 then
1946
                        swooshSound:Play()
1947
                end
1948
                missilePart.Anchored = true
1949
                local progress = frame / 10
1950
                missilePart.Size = Vector3.new(1, 1, progress * 4)
1951
                local magicCirclePart = magicCircleData[4]
1952
                local magicCirclePosition = magicCirclePart.Position
1953
                local missileOffset = 2 * progress * direction
1954
                local missilePosition = magicCirclePosition + missileOffset
1955
                missilePart.CFrame = CFrame.new(missilePosition, missilePosition + direction)
1956
                --missilePart.Transparency = 0.5 * (1 - progress)
1957
                if frame == 10 then
1958
                        touchedConnection = missilePart.Touched:connect(function(hit)
1959
                                if hit.CanCollide and hit.Parent and not GraphicalEffects.missileParts[hit] then
1960
                                        touchedConnection:disconnect()
1961
                                        data[7] = true
1962
                                end
1963
                        end)
1964
                        data[6] = touchedConnection
1965
                end
1966
        else
1967
                missilePart.Anchored = false
1968
                local missilePosition = missilePart.Position
1969
                local targetPosition = targetPart.CFrame * pointOnPart
1970
                local distanceVector = targetPosition - missilePosition
1971
                local elapsedTime = time() - timeCreated
1972
                local targetParent = targetPart.Parent
1973
                if explodeRequested or (targetParent and distanceVector.magnitude < 10) or elapsedTime > lifeTime then
1974
                        GraphicalEffects.missileData[data] = nil
1975
                        GraphicalEffects.missileParts[missilePart] = nil
1976
                        touchedConnection:disconnect()
1977
                        if missilePart.Parent then
1978
                                missilePart:Destroy()
1979
                                local explosion = Instance.new("Explosion")
1980
                                explosion.BlastRadius = 12.5
1981
                                explosion.Position = missilePosition
1982
                                local explosionHitConnection = explosion.Hit:connect(function(hit, distance)
1983
                                        local missileData = GraphicalEffects.missileParts[hit]
1984
                                        if missileData and distance < 3 then
1985
                                                missileData[7] = true
1986
                                        else
1987
                                                pcall(hit.BreakJoints, hit)
1988
                                        end
1989
                                end)
1990
                                explosion.Parent = Workspace
1991
                                TaskScheduler.Schedule(1, explosionHitConnection.disconnect, explosionHitConnection)
1992
                        end
1993
                else
1994
                        local targetInWorkspace = targetPart:IsDescendantOf(Workspace)
1995
                        if targetInWorkspace then
1996
                                direction = distanceVector.unit
1997
                                data[5] = direction
1998
                        end
1999
                        local speed = 14 + elapsedTime * 10
2000
                        local gyroD
2001
                        if elapsedTime < 42.5 and targetInWorkspace then
2002
                                gyroD = 1000 - elapsedTime * 15
2003
                        else
2004
                                gyroD = 100
2005
                                bodyGyro.maxTorque = Vector3.new(0, 0, 0)
2006
                                if elapsedTime + 7.5 < lifeTime then
2007
                                        data[11] = elapsedTime + 7.5
2008
                                end
2009
                        end
2010
                        bodyGyro.D = gyroD
2011
                        bodyGyro.cframe = CFrame.new(Vector3.new(), direction)
2012
                        missilePart.Velocity = missilePart.CFrame.lookVector * speed
2013
                end
2014
        end
2015
end
2016
function GraphicalEffects.ShootMissile(targetPart, pointOnPart, direction, magic_circle_adornee_func, magic_circle_offset, flipped)
2017
        if not magic_circle_offset then
2018
                magic_circle_offset = GraphicalEffects.MAGIC_CIRCLE_DEFAULT_OFFSET
2019
        end
2020
        local targetPosition = targetPart.Position
2021
        local headPosition = chatAdornee.Position
2022
        local origin = CFrame.new(headPosition, headPosition + direction) + direction * magic_circle_offset
2023
        local missilePart = Instance.new("Part")
2024
        local antiGravityForce = Instance.new("BodyForce", missilePart)
2025
        local bodyGyro = Instance.new("BodyGyro", missilePart)
2026
        local explosionSound = Instance.new("Sound", missilePart)
2027
        local swooshSound = Instance.new("Sound", missilePart)
2028
        antiGravityForce.force = Vector3.new(0, 196.2 * 4, 0)
2029
        bodyGyro.D = 1000
2030
        bodyGyro.maxTorque = Vector3.new(1, 1, 1)
2031
        explosionSound.PlayOnRemove = true
2032
        explosionSound.SoundId = "rbxasset://sounds/collide.wav"
2033
        explosionSound.Volume = 1
2034
        missilePart.Anchored = true
2035
        missilePart.BackSurface = "Studs"
2036
        missilePart.BottomSurface = "Studs"
2037
        missilePart.BrickColor = BrickColor.Red()
2038
        missilePart.CFrame = origin
2039
        missilePart.FormFactor = "Custom"
2040
        missilePart.FrontSurface = "Studs"
2041
        missilePart.LeftSurface = "Studs"
2042
        missilePart.Locked = true
2043
        missilePart.RightSurface = "Studs"
2044
        missilePart.Size = Vector3.new(1, 1, 0.2)
2045
        missilePart.TopSurface = "Studs"
2046
        --missilePart.Transparency = 0.5
2047
        swooshSound.Looped = true
2048
        swooshSound.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
2049
        swooshSound.Volume = 0.7
2050
        local magicCircleData = GraphicalEffects.CreateMagicCircle(headPosition + direction * 1000, 0.875, "rbxassetid://127033719", Color3.new(1, 1, 1),
2051
 
2052
40, 4, magic_circle_adornee_func or function() return chatAdornee end, magic_circle_offset)
2053
        local data = {0, missilePart, targetPart, time(), direction, false, false, bodyGyro, swooshSound, magicCircleData, 50, pointOnPart, flipped}
2054
        missilePart.Parent = Workspace
2055
        GraphicalEffects.missileData[data] = true
2056
        GraphicalEffects.missileParts[missilePart] = data
2057
end
2058
2059
function GraphicalEffects.CubicInterpolate(y0, y1, y2, y3, mu)
2060
        local a0, a1, a2, a3, mu2
2061
        mu2 = mu * mu
2062
        a0 = y3 - y2 - y0 + y1
2063
        a1 = y0 - y1 - a0
2064
        a2 = y2 - y0
2065
        a3 = y1
2066
        return a0 * mu * mu2 + a1 * mu2 + a2 * mu + a3
2067
end
2068
function GraphicalEffects.JointCrap(model, cycletime)
2069
        if model then
2070
                local cycletime = cycletime or (0.75 * (1 + math.random() * 4))
2071
                local offsetradius = 0.75
2072
                local rotationoffset = math.pi
2073
                local joints = {}
2074
                local stack = model:GetChildren()
2075
                while #stack ~= 0 do
2076
                        local object = stack[#stack]
2077
                        table.remove(stack)
2078
                        for index, child in ipairs(object:GetChildren()) do
2079
                                table.insert(stack, child)
2080
                        end
2081
                        if object:IsA("JointInstance") then
2082
                                table.insert(joints, object)
2083
                        end
2084
                end
2085
                local rot0 = {}
2086
                local rot1 = {}
2087
                local rot2 = {}
2088
                local rot3 = {}
2089
                local rot4 = {}
2090
                for index, joint in ipairs(joints) do
2091
                        local pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
2092
                        local rot = Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
2093
                        rot0[index] = {joint.C0, joint.C1}
2094
                        rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
2095
                        rot2[index] = {pos, rot}
2096
                        pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
2097
                        rot = rot + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
2098
                        rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
2099
                        rot3[index] = {pos, rot}
2100
                        pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
2101
                        rot = rot + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
2102
                        rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
2103
                        rot4[index] = {pos, rot}
2104
                end
2105
                while model.Parent do
2106
                        for i, j in ipairs(joints) do
2107
                                local pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
2108
                                local rot = rot4[i][2] + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
2109
                                rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
2110
                                rot1[i], rot2[i], rot3[i], rot4[i] = rot2[i], rot3[i], rot4[i], {pos, rot}
2111
                        end
2112
                        local start = tick()
2113
                        while true do
2114
                                local ctime = tick()
2115
                                local elapsed = ctime - start
2116
                                if elapsed > cycletime then
2117
                                        break
2118
                                end
2119
                                local progress = elapsed / cycletime
2120
                                for index, joint in ipairs(joints) do
2121
                                        local v0, v1, v2, v3, v4 = rot0[index], rot1[index], rot2[index], rot3[index], rot4[index]
2122
                                        local p1, p2, p3, p4, r1, r2, r3, r4 = v1[1], v2[1], v3[1], v4[1], v1[2], v2[2], v3[2], v4[2]
2123
                                        local px = GraphicalEffects.CubicInterpolate(p1.x, p2.x, p3.x, p4.x, progress)
2124
                                        local py = GraphicalEffects.CubicInterpolate(p1.y, p2.y, p3.y, p4.y, progress)
2125
                                        local pz = GraphicalEffects.CubicInterpolate(p1.z, p2.z, p3.z, p4.z, progress)
2126
                                        local rx = GraphicalEffects.CubicInterpolate(r1.x, r2.x, r3.x, r4.x, progress)
2127
                                        local ry = GraphicalEffects.CubicInterpolate(r1.y, r2.y, r3.y, r4.y, progress)
2128
                                        local rz = GraphicalEffects.CubicInterpolate(r1.z, r2.z, r3.z, r4.z, progress)
2129
                                        local cframe = CFrame.new(px, py, pz) * CFrame.Angles(rx, ry, rz)
2130
                                        joint.C0 = v0[1] * cframe
2131
                                        joint.C1 = v0[2] * cframe:inverse()
2132
                                end
2133
                                RunService.Stepped:wait()
2134
                        end
2135
                end
2136
        end
2137
end
2138
2139
GraphicalEffects.LASER_WIDTH = 0.15
2140
GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE = 6.25
2141
GraphicalEffects.laser_data = {}
2142
--GraphicalEffects.fragmentation = {}
2143
function GraphicalEffects.AnimateLaserOfDeath(data)
2144
        local frame, directionOrientation, direction, magic_circle_model, laser_part, laser_mesh, magic_circle_part, magic_circle_light,
2145
 
2146
magic_circle_decal_back, magic_circle_decal_front, sound, laser_scale, fragmentation_size, duration, laser_lights, laser_effects, stay, light_effects =
2147
 
2148
unpack(data)
2149
        local laser_color = laser_part.Color
2150
        frame = frame + 1
2151
        data[1] = frame
2152
        local transparency = (frame / duration) ^ stay
2153
        local opacity = 1 - transparency
2154
        if frame == 2 then
2155
                sound:Play()
2156
        end
2157
        if frame == duration then
2158
                pcall(Game.Destroy, magic_circle_model)
2159
                GraphicalEffects.laser_data[data] = nil
2160
        else
2161
                if magic_circle_model.Parent ~= Workspace then
2162
                        pcall(Utility.SetProperty, magic_circle_model, "Parent", Workspace)
2163
                end
2164
                local laser_distance = 0
2165
                local origin = chatAdornee.CFrame
2166
                if not light_effects then
2167
                        direction = (origin * directionOrientation - origin.p).unit
2168
                end
2169
                local magic_circle_position = origin.p + direction * GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE
2170
                local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0, math.tau * frame /
2171
 
2172
25)
2173
                local loop_scale = (laser_scale - 1) / 10
2174
                for x_offset = -loop_scale, loop_scale, 2 do
2175
                        for y_offset = -loop_scale, loop_scale, 2 do
2176
                                local origin_position = magic_circle_cframe * Vector3.new(x_offset, y_offset, 0)
2177
                                for index = 1, 8 do
2178
                                        local part, position
2179
                                        for ray_index = 1, 10 do
2180
                                                local ray = Ray.new(origin_position + direction * (999 * (ray_index - 1)), direction * 999)
2181
                                                part, position = Workspace:FindPartOnRay(ray, magic_circle_model)
2182
                                                if part then
2183
                                                        break
2184
                                                end
2185
                                        end
2186
                                        if part then
2187
                                                laser_distance = (position - origin_position).magnitude
2188
                                                if frame % 8 == 1 and index == 1 then
2189
                                                        Instance.new("Explosion", Workspace).Position = position
2190
                                                end
2191
                                                if not part:IsA("Terrain") then
2192
                                                        pcall(part.BreakJoints, part)
2193
                                                        local is_block = part:IsA("Part") and part.Shape == Enum.PartType.Block
2194
                                                        local mass = part:GetMass()
2195
                                                        local size = part.Size
2196
                                                        if (is_block and ((size.X < fragmentation_size and size.Y < fragmentation_size and size.Z <
2197
 
2198
fragmentation_size) or (not part.Anchored and mass < 750))) or (not is_block and mass < 250000) then
2199
                                                                local part_transparency = math.max(part.Transparency + 0.007 * fragmentation_size, 0.5)
2200
                                                                if part_transparency >= 0.5 then -- temporarily to minimize debris
2201
                                                                        pcall(Game.Destroy, part)
2202
                                                                else
2203
                                                                        local cframe = part.CFrame
2204
                                                                        part.Anchored = false
2205
                                                                        part.BrickColor = BrickColor.new("Medium stone grey")
2206
                                                                        part.CanCollide = true
2207
                                                                        if part:IsA("FormFactorPart") then
2208
                                                                                part.FormFactor = "Custom"
2209
                                                                        end
2210
                                                                        part.Size = size - Vector3.new(0.135, 0.135, 0.135) * fragmentation_size
2211
                                                                        part.Transparency = part_transparency
2212
                                                                        part.CFrame = cframe + direction * 5
2213
                                                                        part.Velocity = part.Velocity + direction * 40
2214
                                                                end
2215
                                                        elseif is_block then
2216
                                                                local parts = {part}
2217
                                                                local model = Instance.new("Model", part.Parent)
2218
                                                                model.Name = "Fragments"
2219
                                                                if size.X >= fragmentation_size then
2220
                                                                        size = Vector3.new(0.5, 1, 1) * size
2221
                                                                        local archivable = part.Archivable
2222
                                                                        local cframe = part.CFrame
2223
                                                                        part.FormFactor = "Custom"
2224
                                                                        part.Size = size
2225
                                                                        part.Archivable = true
2226
                                                                        local part_clone = part:Clone()
2227
                                                                        part.Archivable = archivable
2228
                                                                        part_clone.Archivable = archivable
2229
                                                                        part.CFrame = cframe * CFrame.new(-0.5 * size.X, 0, 0)
2230
                                                                        part_clone.CFrame = cframe * CFrame.new(0.5 * size.X, 0, 0)
2231
                                                                        part_clone.Parent = model
2232
                                                                        parts[2] = part_clone
2233
                                                                end
2234
                                                                if size.Y >= fragmentation_size then
2235
                                                                        size = Vector3.new(1, 0.5, 1) * size
2236
                                                                        for part_index = 1, #parts do
2237
                                                                                local part = parts[part_index]
2238
                                                                                local archivable = part.Archivable
2239
                                                                                local cframe = part.CFrame
2240
                                                                                part.FormFactor = "Custom"
2241
                                                                                part.Size = size
2242
                                                                                part.Archivable = true
2243
                                                                                local part_clone = part:Clone()
2244
                                                                                part.Archivable = archivable
2245
                                                                                part_clone.Archivable = archivable
2246
                                                                                part.CFrame = cframe * CFrame.new(0, -0.5 * size.Y, 0)
2247
                                                                                part_clone.CFrame = cframe * CFrame.new(0, 0.5 * size.Y, 0)
2248
                                                                                part_clone.Parent = model
2249
                                                                                table.insert(parts, part_clone)
2250
                                                                        end
2251
                                                                end
2252
                                                                if size.Z >= fragmentation_size then
2253
                                                                        size = Vector3.new(1, 1, 0.5) * size
2254
                                                                        for part_index = 1, #parts do
2255
                                                                                local part = parts[part_index]
2256
                                                                                local archivable = part.Archivable
2257
                                                                                local cframe = part.CFrame
2258
                                                                                part.FormFactor = "Custom"
2259
                                                                                part.Size = size
2260
                                                                                part.Archivable = true
2261
                                                                                local part_clone = part:Clone()
2262
                                                                                part.Archivable = archivable
2263
                                                                                part_clone.Archivable = archivable
2264
                                                                                part.CFrame = cframe * CFrame.new(0, 0, -0.5 * size.Z)
2265
                                                                                part_clone.CFrame = cframe * CFrame.new(0, 0, 0.5 * size.Z)
2266
                                                                                part_clone.Parent = model
2267
                                                                                table.insert(parts, part_clone)
2268
                                                                        end
2269
                                                                end
2270
                                                                for _, part in ipairs(parts) do
2271
                                                                        part:MakeJoints()
2272
                                                                end
2273
                                                        else
2274
                                                                break
2275
                                                        end
2276
                                                end
2277
                                        else
2278
                                                laser_distance = 9990
2279
                                                break
2280
                                        end
2281
                                end
2282
                        end
2283
                end
2284
                local laser_cframe = magic_circle_cframe * CFrame.Angles(-0.5 * math.pi, 0, 0)
2285
                local laser_width = GraphicalEffects.LASER_WIDTH * opacity * laser_scale
2286
                local laser_mesh_offset = Vector3.new(0, 0.5 * laser_distance, 0)      
2287
                laser_part.CFrame = laser_cframe
2288
                if laser_effects then
2289
                        local laser_effect_data_1, laser_effect_data_2 = laser_effects[1], laser_effects[2]
2290
                        local laser_effect_1, laser_effect_mesh_1 = laser_effect_data_1[1], laser_effect_data_1[2]
2291
                        local laser_effect_2, laser_effect_mesh_2 = laser_effect_data_2[1], laser_effect_data_2[2]
2292
                        laser_effect_1.CFrame = laser_cframe
2293
                        laser_effect_2.CFrame = laser_cframe
2294
                        laser_effect_mesh_1.Offset = laser_mesh_offset
2295
                        laser_effect_mesh_2.Offset = laser_mesh_offset
2296
                        local game_time = time()
2297
                        local effect_scale_1 = 0.5 + 0.5 * math.sin(16 * math.pi * game_time)
2298
                        local effect_scale_2 = 0.5 + 0.5 * math.cos(16 * math.pi * game_time)
2299
                        laser_effect_mesh_1.Scale = 5 * Vector3.new(laser_width * effect_scale_1, laser_distance, laser_width * effect_scale_1)
2300
                        laser_effect_mesh_2.Scale = 5 * Vector3.new(laser_width * effect_scale_2, laser_distance, laser_width * effect_scale_2)
2301
                        laser_width = laser_width * 0.25
2302
                end
2303
                laser_mesh.Offset = laser_mesh_offset                  
2304
                laser_mesh.Scale = 5 * Vector3.new(laser_width, laser_distance, laser_width)
2305
                magic_circle_part.CFrame = magic_circle_cframe
2306
                magic_circle_light.Brightness = opacity
2307
                magic_circle_decal_back.Transparency = transparency
2308
                magic_circle_decal_front.Transparency = transparency
2309
                if light_effects then
2310
                        for index, data in ipairs(laser_lights) do
2311
                                local laser_spotlight_part, laser_spotlight = data[1], data[2]
2312
                                local laser_spotlight_offset = 30 * (index - 1)
2313
                                if laser_spotlight_offset <= laser_distance then
2314
                                        laser_spotlight_part.CFrame = magic_circle_cframe * CFrame.new(0, 0, -laser_spotlight_offset)
2315
                                        laser_spotlight.Brightness = opacity
2316
                                        laser_spotlight.Enabled = true
2317
                                else
2318
                                        laser_spotlight.Enabled = false
2319
                                end
2320
                        end
2321
                end
2322
        end
2323
end
2324
function GraphicalEffects.ShootLaserOfDeath(target, data)
2325
        if chatAdornee then
2326
                data = data or {}
2327
                local brickcolor = data.brickcolor or BrickColor.new("Really black")
2328
                local duration = data.duration or 40
2329
                local fragmentation_size = data.fragmentation_size or 3
2330
                local laser_scale = data.laser_scale or 1
2331
                local light_color = data.light_color or Color3.new(1, 0.5, 1)
2332
                local magic_circle_image = data.magic_circle_image or "rbxassetid://122610943"
2333
                local magic_circle_scale = data.magic_circle_scale or 1
2334
                local sound_volume = data.sound_volume or 1 / 3
2335
                local special_effects = data.special_effects
2336
                local stay = data.stay or 4
2337
                local origin = chatAdornee.CFrame
2338
                local directionOrientation = origin:pointToObjectSpace(target)
2339
                local direction = (target - origin.p).unit
2340
                local magic_circle_position = origin.p + direction * GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE
2341
                local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
2342
                local magic_circle_model = Instance.new("Model")
2343
                local laser_part = Instance.new("Part", magic_circle_model)
2344
                local laser_mesh = Instance.new("CylinderMesh", laser_part)
2345
                local magic_circle_part = Instance.new("Part", magic_circle_model)
2346
                local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
2347
                local magic_circle_light = Instance.new("PointLight", magic_circle_part)
2348
                local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
2349
                local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
2350
                local sound = Instance.new("Sound", magic_circle_part)
2351
                sound.Pitch = 1.25
2352
                sound.SoundId = "rbxassetid://2248511"
2353
                sound.Volume = sound_volume
2354
                magic_circle_model.Archivable = false
2355
                laser_part.Anchored = true
2356
                laser_part.BottomSurface = "Smooth"
2357
                laser_part.BrickColor = brickcolor
2358
                laser_part.CanCollide = false
2359
                laser_part.CFrame = magic_circle_cframe * CFrame.Angles(-0.5 * math.pi, 0, 0)
2360
                laser_part.FormFactor = "Custom"
2361
                laser_part.Locked = true
2362
                laser_part.Size = Vector3.new(0.2, 0.2, 0.2)
2363
                laser_part.TopSurface = "Smooth"
2364
                laser_mesh.Offset = Vector3.new(0, 0, 0)
2365
                laser_mesh.Name = "Mesh"
2366
                laser_mesh.Scale = 5 * laser_scale * Vector3.new(GraphicalEffects.LASER_WIDTH, 0, GraphicalEffects.LASER_WIDTH)
2367
                magic_circle_part.Anchored = true
2368
                magic_circle_part.BottomSurface = "Smooth"
2369
                magic_circle_part.CanCollide = false
2370
                magic_circle_part.CFrame = magic_circle_cframe
2371
                magic_circle_part.FormFactor = "Custom"
2372
                magic_circle_part.Locked = true
2373
                magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
2374
                magic_circle_part.TopSurface = "Smooth"
2375
                magic_circle_part.Transparency = 1
2376
                magic_circle_mesh.Scale = Vector3.new(60, 60, 0) * magic_circle_scale
2377
                magic_circle_light.Color = light_color
2378
                magic_circle_light.Range = 16 * magic_circle_scale
2379
                magic_circle_light.Shadows = true
2380
                magic_circle_decal_back.Face = "Back"
2381
                magic_circle_decal_back.Texture = magic_circle_image
2382
                magic_circle_decal_front.Face = "Front"
2383
                magic_circle_decal_front.Texture = magic_circle_image
2384
                magic_circle_model.Parent = Workspace
2385
                local laser_color = brickcolor.Color
2386
                local laser_lights = {}
2387
                local light_effects = laser_color.r + laser_color.g + laser_color.b > 0.25
2388
                if light_effects then
2389
                        local laser_spotlight_part_template = Instance.new("Part")
2390
                        local laser_spotlight_light_template = Instance.new("SpotLight", laser_spotlight_part_template)
2391
                        laser_spotlight_part_template.Anchored = true
2392
                        laser_spotlight_part_template.Anchored = true
2393
                        laser_spotlight_part_template.BottomSurface = "Smooth"
2394
                        laser_spotlight_part_template.CanCollide = false
2395
                        laser_spotlight_part_template.FormFactor = "Custom"
2396
                        laser_spotlight_part_template.Locked = true
2397
                        laser_spotlight_part_template.Size = Vector3.new(0.2, 0.2, 0.2)
2398
                        laser_spotlight_part_template.TopSurface = "Smooth"
2399
                        laser_spotlight_part_template.Transparency = 1
2400
                        laser_spotlight_light_template.Angle = 45
2401
                        laser_spotlight_light_template.Color = laser_color
2402
                        laser_spotlight_light_template.Enabled = true
2403
                        laser_spotlight_light_template.Name = "Light"
2404
                        laser_spotlight_light_template.Range = 60
2405
                        for index = 1, 40 do
2406
                                local laser_spotlight_part = laser_spotlight_part_template:Clone()
2407
                                laser_spotlight_part.CFrame = magic_circle_cframe * CFrame.new(0, 0, -30 * (index - 1))
2408
                                laser_spotlight_part.Parent = magic_circle_model
2409
                                laser_lights[index] = {laser_spotlight_part, laser_spotlight_part.Light}
2410
                        end
2411
                end
2412
                local laser_effects
2413
                if special_effects then
2414
                        laser_effects = {}
2415
                        local laser_effect_1 = laser_part:Clone()
2416
                        laser_effect_1.BrickColor = special_effects
2417
                        laser_effect_1.Transparency = 0.5
2418
                        local laser_effect_2 = laser_effect_1:Clone()
2419
                        laser_effects[1], laser_effects[2] = {laser_effect_1, laser_effect_1.Mesh}, {laser_effect_2, laser_effect_2.Mesh}
2420
                        laser_effect_1.Parent = magic_circle_model
2421
                        laser_effect_2.Parent = magic_circle_model
2422
                end
2423
                GraphicalEffects.laser_data[{0, directionOrientation, direction, magic_circle_model, laser_part, laser_mesh, magic_circle_part,
2424
 
2425
magic_circle_light, magic_circle_decal_back, magic_circle_decal_front, sound, laser_scale, fragmentation_size, duration, laser_lights, laser_effects, stay,
2426
 
2427
light_effects}] = true
2428
        end
2429
end
2430
2431
function GraphicalEffects.SpawnSapientRock(position)
2432
	local part = Instance.new("Part", Workspace)
2433
	local size = 8 + math.random(0, 5)
2434
	part.BottomSurface = "Smooth"
2435
	part.TopSurface = "Smooth"
2436
	part.Material = "Slate"
2437
	part.Locked = true
2438
	part.Shape = "Ball"
2439
	part.FormFactor = "Custom"
2440
	part.Size = Vector3.new(size, size, size)
2441
	part.Position = position
2442
	local bodypos = Instance.new("BodyPosition", part)
2443
	bodypos.maxForce = Vector3.new(0, 0, 0)
2444
	local angry = false
2445
	local damage_ready = true
2446
	local torso_following
2447
	local torso_changed = -1000
2448
	local touched_conn = part.Touched:connect(function(hit)
2449
		local character = hit.Parent
2450
		if character then
2451
			local humanoid
2452
			for _, child in ipairs(character:GetChildren()) do
2453
				if child:IsA("Humanoid") then
2454
					humanoid = child
2455
					break
2456
				end
2457
			end
2458
			if humanoid then
2459
				if angry then
2460
					if damage_ready then
2461
						damage_ready = false
2462
						humanoid:TakeDamage(100)
2463
						wait(1)
2464
						damage_ready = true
2465
						angry = false
2466
						part.BrickColor = BrickColor.new("Medium stone grey")
2467
					end
2468
				else
2469
					local torso = humanoid.Torso
2470
					if torso then
2471
						torso_following = torso
2472
						torso_changed = tick()
2473
					end
2474
				end
2475
			end
2476
		end
2477
	end)
2478
	TaskScheduler.Start(function()
2479
		while part.Parent == Workspace do
2480
			if torso_following then
2481
				bodypos.position = torso_following.Position
2482
				if tick() - torso_changed > 60 or not torso_following.Parent then
2483
					torso_following = nil
2484
					bodypos.maxForce = Vector3.new(0, 0, 0)
2485
					angry = false
2486
					part.BrickColor = BrickColor.new("Medium stone grey")
2487
				else
2488
					local speed = angry and Vector3.new(16, 16, 16) or Vector3.new(6, 0, 6)
2489
					bodypos.maxForce = part:GetMass() * speed
2490
					if part.Position.Y < -250 then
2491
						part.Velocity = Vector3.new()
2492
						part.Position = torso_following.Position + Vector3.new(0, 80, 0)
2493
						part.BrickColor = BrickColor.new("Bright red")
2494
						angry = true
2495
						torso_changed = tick()
2496
					end
2497
				end
2498
			end
2499
			RunService.Stepped:wait()
2500
		end
2501
		touched_conn:disconnect()
2502
	end)
2503
	TaskScheduler.Start(function()
2504
		while part.Parent == Workspace do
2505
			wait(25 + math.random() * 10)
2506
			local next_size = 8 + math.random() * 5
2507
			if math.random(100) == 1 then
2508
				next_size = next_size * (2 + 6 * math.random())
2509
			end
2510
			next_size = math.floor(next_size + 0.5)
2511
			local start_time = tick()
2512
			local mesh = Instance.new("SpecialMesh", part)
2513
			mesh.MeshType = "Sphere"
2514
			repeat
2515
				local elapsed_time = tick() - start_time
2516
				local alpha = math.cos(elapsed_time * math.pi * 0.5)
2517
				local interpolated_size = size * alpha + next_size * (1 - alpha)
2518
				local size_vector = Vector3.new(interpolated_size, interpolated_size, interpolated_size)
2519
				local cframe = part.CFrame
2520
				part.Size = size_vector
2521
				part.CFrame = cframe
2522
				mesh.Scale = size_vector / part.Size
2523
				RunService.Stepped:wait()
2524
			until tick() - start_time >= 1
2525
			mesh:Destroy()
2526
			local cframe = part.CFrame
2527
			part.Size = Vector3.new(next_size, next_size, next_size)
2528
			part.CFrame = cframe
2529
			size = next_size
2530
		end
2531
	end)
2532
end
2533
2534
function GraphicalEffects.MainLoop()
2535
        RunService.Stepped:wait()
2536
        for data in pairs(GraphicalEffects.magicCircleData) do
2537
                GraphicalEffects.AnimateMagicCircle(data)
2538
        end
2539
        for data in pairs(GraphicalEffects.laser_data) do
2540
                GraphicalEffects.AnimateLaserOfDeath(data)
2541
        end
2542
        for data in pairs(GraphicalEffects.missileData) do
2543
                GraphicalEffects.AnimateMissile(data)
2544
        end
2545
end
2546
TaskScheduler.Start(function()
2547
        while true do
2548
                GraphicalEffects.MainLoop()
2549
        end
2550
end)
2551
2552
PlayerControl = {};
2553
2554
PlayerControl.fly_acceleration = 10
2555
PlayerControl.fly_basespeed = 250
2556
PlayerControl.fly_speed = PlayerControl.fly_basespeed
2557
PlayerControl.featherfallEnabled = true
2558
PlayerControl.pushable = false
2559
PlayerControl.rolling = false
2560
PlayerControl.rollingAngle = 0
2561
PlayerControl.rollingOffset = 0
2562
PlayerControl.rollingMaxOffset = 3
2563
PlayerControl.rollingSpeed = 1 / 50
2564
PlayerControl.characterEnabled = false
2565
PlayerControl.characterMode = "normal"
2566
local character = nil
2567
local flying, flyingMomentum, flyingTilt = false, Vector3.new(), 0
2568
local pose, regeneratingHealth, jumpDebounce = "Standing", false, false
2569
-- TODO: make local variables public
2570
local model, bodyColors, leftArmMesh, leftLegMesh, rightArmMesh, rightLegMesh, torsoMesh, wildcardHat, wildcardHandle, wildcardMesh, pants, shirt, humanoid, 
2571
2572
head, leftArm, leftLeg, rightArm, rightLeg, torso, rootPart, rootJoint, face, soundFreeFalling, soundGettingUp, soundRunning, leftHip, leftShoulder, 
2573
2574
rightHip, rightShoulder, neck, wildcardWeld, feetPart, feetWeld, feetTouchInterest, bodyGyro, bodyVelocity, headMesh, torsoLight
2575
local AnimateCharacter
2576
local UserInterface = game:service'UserInputService'
2577
local chatBubbles = {}
2578
local chatCharacterLimit = 240
2579
function PlayerControl.CreateCharacter()
2580
	local characterMode = PlayerControl.characterMode
2581
	if characterMode == "normal" then
2582
		if not PlayerControl.characterEnabled then
2583
			return
2584
		end
2585
		local appearance = CharacterAppearance.GetDefaultAppearance()
2586
		local active = true
2587
		local torsoCFrame = (torso and torso.CFrame) or PlayerControl.torso_cframe or CFrame.new(0, 10, 0)
2588
		if torsoCFrame.p.Y < -450 then
2589
			torsoCFrame = CFrame.new(0, 10, 0)
2590
		end
2591
		local rootPartCFrame = (rootPart and rootPart.CFrame) or PlayerControl.torso_cframe or CFrame.new(0, 10, 0)
2592
		if rootPartCFrame.p.Y < -450 then
2593
			rootPartCFrame = CFrame.new(0, 10, 0)
2594
		end
2595
		local cameraCFrame = Camera.CoordinateFrame
2596
		local connections = {}
2597
		local feetTouching = {}
2598
		local previousWalkSpeed = 0
2599
		local prevLeftHip, prevLeftShoulder, prevRightHip, prevRightShoulder = leftHip, leftShoulder, rightHip, rightShoulder
2600
		model = Instance.new("Model")
2601
		humanoid = Instance.new("Humanoid", model)
2602
		head = Instance.new("Part", model)
2603
		leftArm = Instance.new("Part", model)
2604
		leftLeg = Instance.new("Part", model)
2605
		rightArm = Instance.new("Part", model)
2606
		rightLeg = Instance.new("Part", model)
2607
		torso = Instance.new("Part", model)
2608
		rootPart = Instance.new("Part", model)
2609
		soundFallingDown = Instance.new("Sound", head)
2610
		soundFreeFalling = Instance.new("Sound", head)
2611
		soundGettingUp = Instance.new("Sound", head)
2612
		soundJumping = Instance.new("Sound", head)
2613
		soundRunning = Instance.new("Sound", head)
2614
		leftHip = Instance.new("Motor", torso)
2615
		leftShoulder = Instance.new("Motor", torso)
2616
		rightHip = Instance.new("Motor", torso)
2617
		rightShoulder = Instance.new("Motor", torso)
2618
		neck = Instance.new("Motor", torso)
2619
		rootJoint = Instance.new("Motor", rootPart)
2620
		feetPart = Instance.new("Part", model)
2621
		feetWeld = Instance.new("Weld", torso)
2622
		bodyGyro = Instance.new("BodyGyro", rootPart)
2623
		bodyVelocity = Instance.new("BodyVelocity", rootPart)
2624
		model.Archivable = false
2625
		model.Name = user_name or Player.Name
2626
		model.PrimaryPart = head
2627
		humanoid.LeftLeg = leftLeg
2628
		humanoid.RightLeg = rightLeg
2629
		humanoid.Torso = rootPart
2630
		head.CFrame = torsoCFrame * CFrame.new(0, 1.5, 0)
2631
		head.FormFactor = "Symmetric"
2632
		head.Locked = true
2633
		head.Name = "Head"
2634
		head.Size = Vector3.new(2, 1, 1)
2635
		head.TopSurface = "Smooth"
2636
		leftArm.CanCollide = false
2637
		leftArm.CFrame = torsoCFrame * CFrame.new(-1.5, 0, 0)
2638
		leftArm.FormFactor = "Symmetric"
2639
		leftArm.Locked = true
2640
		leftArm.Name = "Left Arm"
2641
		leftArm.Size = Vector3.new(1, 2, 1)
2642
		leftLeg.BottomSurface = "Smooth"
2643
		leftLeg.CanCollide = false
2644
		leftLeg.CFrame = torsoCFrame * CFrame.new(-0.5, -2, 0)
2645
		leftLeg.FormFactor = "Symmetric"
2646
		leftLeg.Locked = true
2647
		leftLeg.Name = "Left Leg"
2648
		leftLeg.Size = Vector3.new(1, 2, 1)
2649
		leftLeg.TopSurface = "Smooth"
2650
		rightArm.CanCollide = false
2651
		rightArm.CFrame = torsoCFrame * CFrame.new(1.5, 0, 0)
2652
		rightArm.FormFactor = "Symmetric"
2653
		rightArm.Locked = true
2654
		rightArm.Name = "Right Arm"
2655
		rightArm.Size = Vector3.new(1, 2, 1)
2656
		rightLeg.BottomSurface = "Smooth"
2657
		rightLeg.CanCollide = false
2658
		rightLeg.CFrame = torsoCFrame * CFrame.new(0.5, -2, 0)
2659
		rightLeg.FormFactor = "Symmetric"
2660
		rightLeg.Locked = true
2661
		rightLeg.Name = "Right Leg"
2662
		rightLeg.Size = Vector3.new(1, 2, 1)
2663
		rightLeg.TopSurface = "Smooth"
2664
		torso.CFrame = torsoCFrame
2665
		torso.FormFactor = "Symmetric"
2666
		torso.LeftSurface = "Weld"
2667
		torso.Locked = true
2668
		torso.RightSurface = "Weld"
2669
		torso.Name = "Torso"
2670
		torso.Size = Vector3.new(2, 2, 1)
2671
		rootPart.BottomSurface = "Smooth"
2672
		rootPart.BrickColor = BrickColor.Blue()
2673
		rootPart.CFrame = rootPartCFrame
2674
		rootPart.FormFactor = "Symmetric"
2675
		rootPart.LeftSurface = "Weld"
2676
		rootPart.Locked = true
2677
		rootPart.RightSurface = "Weld"
2678
		rootPart.Name = "HumanoidRootPart"
2679
		rootPart.Size = Vector3.new(2, 2, 1)
2680
		rootPart.TopSurface = "Smooth"
2681
		rootPart.Transparency = 1
2682
		soundFreeFalling.Archivable = false
2683
		soundFreeFalling.SoundId = "rbxasset://sounds/swoosh.wav"
2684
		soundGettingUp.Archivable = false
2685
		soundGettingUp.SoundId = "rbxasset://sounds/hit.wav"
2686
		soundRunning.Archivable = false
2687
		soundRunning.SoundId = "rbxasset://sounds/bfsl-minifigfoots1.mp3"
2688
		soundRunning.Looped = true
2689
		leftHip.C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
2690
		leftHip.C1 = CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
2691
		leftHip.MaxVelocity = 0.1
2692
		leftHip.Name = "Left Hip"
2693
		leftHip.Part0 = torso
2694
		leftHip.Part1 = leftLeg
2695
		leftShoulder.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
2696
		leftShoulder.C1 = CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
2697
		leftShoulder.MaxVelocity = 0.15
2698
		leftShoulder.Name = "Left Shoulder"
2699
		leftShoulder.Part0 = torso
2700
		leftShoulder.Part1 = leftArm
2701
		rightHip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
2702
		rightHip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
2703
		rightHip.MaxVelocity = 0.1
2704
		rightHip.Name = "Right Hip"
2705
		rightHip.Part0 = torso
2706
		rightHip.Part1 = rightLeg
2707
		rightShoulder.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
2708
		rightShoulder.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
2709
		rightShoulder.MaxVelocity = 0.15
2710
		rightShoulder.Name = "Right Shoulder"
2711
		rightShoulder.Part0 = torso
2712
		rightShoulder.Part1 = rightArm
2713
		if prevLeftHip then
2714
			leftHip.CurrentAngle = prevLeftHip.CurrentAngle
2715
			leftHip.DesiredAngle = prevLeftHip.DesiredAngle
2716
		end
2717
		if prevLeftShoulder then
2718
			leftShoulder.CurrentAngle = prevLeftShoulder.CurrentAngle
2719
			leftShoulder.DesiredAngle = prevLeftShoulder.DesiredAngle
2720
		end
2721
		if prevRightHip then
2722
			rightHip.CurrentAngle = prevRightHip.CurrentAngle
2723
			rightHip.DesiredAngle = prevRightHip.DesiredAngle
2724
		end
2725
		if prevRightShoulder then
2726
			rightShoulder.CurrentAngle = prevRightShoulder.CurrentAngle
2727
			rightShoulder.DesiredAngle = prevRightShoulder.DesiredAngle
2728
		end
2729
		neck.C0 = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
2730
		neck.C1 = CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
2731
		neck.Name = "Neck"
2732
		neck.Part0 = torso
2733
		neck.Part1 = head
2734
		rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
2735
		rootJoint.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
2736
		rootJoint.Name = "RootJoint"
2737
		rootJoint.Part0 = rootPart
2738
		rootJoint.Part1 = torso
2739
		feetPart.BottomSurface = "Smooth"
2740
		feetPart.CanCollide = false
2741
		feetPart.CFrame = torsoCFrame * CFrame.new(0, -3.1, 0)
2742
		feetPart.FormFactor = "Custom"
2743
		feetPart.Locked = true
2744
		feetPart.Name = "Platform"
2745
		feetPart.Size = Vector3.new(1.8, 0.2, 0.8)
2746
		feetPart.TopSurface = "Smooth"
2747
		feetPart.Transparency = 1
2748
		feetWeld.C0 = CFrame.new(0, -3, 0)
2749
		feetWeld.C1 = CFrame.new(0, 0.1, 0)
2750
		feetWeld.Name = "PlatformWeld"
2751
		feetWeld.Part0 = torso
2752
		feetWeld.Part1 = feetPart
2753
		table.insert(connections, feetPart.Touched:connect(function(hit)
2754
			feetTouching[hit] = true
2755
		end))
2756
		table.insert(connections, feetPart.TouchEnded:connect(function(hit)
2757
			feetTouching[hit] = nil
2758
		end))
2759
		feetTouchInterest = feetPart:FindFirstChild("TouchInterest")
2760
		bodyGyro.D = 3250
2761
		bodyGyro.P = 400000
2762
		bodyGyro.maxTorque = Vector3.new(1000000000, 0, 1000000000)
2763
		bodyVelocity.P = 5000
2764
		bodyVelocity.maxForce = Vector3.new(0, 0, 0)
2765
		bodyVelocity.velocity = Vector3.new(0, 0, 0)
2766
		torsoLight = Instance.new("PointLight", torso)
2767
		torsoLight.Brightness = 0.4
2768
		torsoLight.Color = Color3.new(1, 1, 1)
2769
		torsoLight.Range = 16
2770
		torsoLight.Shadows = true
2771
		local ff1, ff2, ff3, ff4, ff5, ff6, ff7, ff8, ff9 = Instance.new("ForceField", head), Instance.new("ForceField", leftArm), Instance.new("ForceField", leftLeg), Instance.new("ForceField", rightArm), Instance.new("ForceField", rightLeg), Instance.new("ForceField", torso), Instance.new("ForceField", wildcardHandle), Instance.new("ForceField", feetPart), Instance.new("ForceField", rootPart)
2772
		local forcefields = {[ff1] = head, [ff2] = leftArm, [ff3] = leftLeg, [ff4] = rightArm, [ff5] = rightLeg, [ff6] = torso, [ff7] = wildcardHandle, [ff8] = feetPart, [ff9] = rootPart}	
2773
		local objects = {[humanoid] = true, [head] = true, [leftArm] = true, [leftLeg] = true, [rightArm] = true, [rightLeg] = true, [torso] = true, [rootPart] = true, [rootJoint] = true, [soundFreeFalling] = true, [soundGettingUp] = true, [soundRunning] = true, [leftHip] = true, [leftShoulder] = true, [rightHip] = true, [rightShoulder] = true, [neck] = true, [feetPart] = true, [feetWeld] = true, [feetTouchInterest] = true, [bodyGyro] = true, [bodyVelocity] = true, [ff1] = true, [ff2] = true, [ff3] = true, [ff4] = true, [ff5] = true, [ff6] = true, [ff7] = true, [ff8] = true, [ff9] = true}		
2774
		local tshirtUrl = appearance.tshirt
2775
		if tshirtUrl then
2776
			local tshirt = Instance.new("Decal", torso)
2777
			tshirt.Name = "roblox"
2778
			tshirt.Texture = tshirtUrl
2779
			objects[tshirt] = true
2780
		end
2781
		for _, template in ipairs(appearance.characterObjects) do
2782
			local object = template:Clone()
2783
			local newObjects = {object}
2784
			for _, object in ipairs(newObjects) do
2785
				objects[object] = true
2786
				for _, child in ipairs(object:GetChildren()) do
2787
					table.insert(newObjects, child)
2788
				end				
2789
			end
2790
			if object:IsA("BodyColors") then
2791
				head.BrickColor = object.HeadColor
2792
				leftArm.BrickColor = object.LeftArmColor
2793
				leftLeg.BrickColor = object.LeftLegColor
2794
				rightArm.BrickColor = object.RightArmColor
2795
				rightLeg.BrickColor = object.RightLegColor
2796
				torso.BrickColor = object.TorsoColor
2797
			elseif object:IsA("Hat") then
2798
				local handle = object:FindFirstChild("Handle")
2799
				if handle and handle:IsA("BasePart") then
2800
					local weld = Instance.new("Weld", head)
2801
					weld.C0 = CFrame.new(0, 0.5, 0)
2802
					local attachmentPos = object.AttachmentPos
2803
					local attachmentRight = object.AttachmentRight
2804
					local attachmentUp = object.AttachmentUp
2805
					local attachmentForward = object.AttachmentForward
2806
					weld.C1 = CFrame.new(attachmentPos.X, attachmentPos.Y, attachmentPos.Z,
2807
										 attachmentRight.X, attachmentUp.X, -attachmentForward.X,
2808
										 attachmentRight.Y, attachmentUp.Y, -attachmentForward.Y,
2809
										 attachmentRight.Z, attachmentUp.Z, -attachmentForward.Z)
2810
					weld.Name = "HeadWeld"
2811
					weld.Part0 = head
2812
					weld.Part1 = handle
2813
					handle.Parent = model
2814
					local antiGravity = Instance.new("BodyForce", handle)
2815
					antiGravity.force = Vector3.new(0, handle:GetMass() * 196.2, 0)
2816
					objects[object] = false
2817
					object.Parent = nil
2818
					objects[weld] = true
2819
				end
2820
			end
2821
			object.Parent = model
2822
		end
2823
		local facePresent = false
2824
		local headMeshPresent = false
2825
		for _, template in ipairs(appearance.headObjects) do
2826
			local object = template:Clone()
2827
			local newObjects = {object}
2828
			for _, object in ipairs(newObjects) do
2829
				objects[object] = true
2830
				for _, child in ipairs(object:GetChildren()) do
2831
					table.insert(newObjects, child)
2832
				end				
2833
			end
2834
			if object:IsA("DataModelMesh") then
2835
				headMeshPresent = true
2836
			elseif object:IsA("Decal") then
2837
				facePresent = true
2838
			end
2839
			object.Parent = head
2840
		end
2841
		if not facePresent then
2842
			local face = Instance.new("Decal", head)
2843
			face.Texture = "rbxasset://textures/face.png"
2844
			objects[face] = true
2845
		end
2846
		if not headMeshPresent then
2847
			local headMesh = Instance.new("SpecialMesh", head)
2848
			headMesh.Scale = Vector3.new(1.25, 1.25, 1.25)
2849
			objects[headMesh] = true
2850
		end
2851
		table.insert(connections, model.DescendantAdded:connect(function(object)
2852
			local success, is_localscript = pcall(Game.IsA, object, "LocalScript")
2853
			if success and is_localscript then
2854
				pcall(Utility.SetProperty, object, "Disabled", true)
2855
				local changed_connection = pcall(object.Changed.connect, object.Changed, function(property)
2856
					if property == "Disabled" and not object.Disabled then
2857
						pcall(Utility.SetProperty, object, "Disabled", true)
2858
						object:Destroy()
2859
					end
2860
				end)
2861
			end
2862
			if not objects[object] then
2863
				object:Destroy()
2864
			end
2865
		end))
2866
		model.Parent = Workspace
2867
		Player.Character = model
2868
		Camera.CameraSubject = humanoid
2869
		Camera.CameraType = "Track"
2870
		Camera.CoordinateFrame = cameraCFrame
2871
		local IsStanding
2872
		local RegenerateHealth
2873
		local ResetCharacter
2874
		function IsStanding()
2875
			return not not next(feetTouching)
2876
		end
2877
		function RegenerateHealth()
2878
			if humanoid.Health < 1 then
2879
				humanoid.Health = 100
2880
			elseif not regeneratingHealth then
2881
				regeneratingHealth = true
2882
				local elapsedTime = wait(1)
2883
				regeneratingHealth = false
2884
				if humanoid.Health < 100 then
2885
					humanoid.Health = math.min(humanoid.Health + elapsedTime, 100)
2886
				end
2887
			end
2888
		end
2889
		function ResetCharacter()
2890
			for index, connection in ipairs(connections) do
2891
				connection:disconnect()
2892
			end
2893
			active = false
2894
		end
2895
		table.insert(connections, model.AncestryChanged:connect(ResetCharacter))
2896
		table.insert(connections, model.DescendantRemoving:connect(function(object)
2897
			local parent = forcefields[object]
2898
			if parent then
2899
				forcefields[object] = nil
2900
				local new_forcefield = Instance.new("ForceField")
2901
				forcefields[new_forcefield] = parent
2902
				objects[new_forcefield] = true
2903
				new_forcefield.Parent = parent
2904
			elseif objects[object] then
2905
				ResetCharacter()
2906
			end
2907
		end))
2908
		table.insert(connections, humanoid.HealthChanged:connect(RegenerateHealth))
2909
		table.insert(connections, humanoid.Climbing:connect(function() pose = "Climbing" end))
2910
		table.insert(connections, humanoid.FallingDown:connect(function(state)  pose = "FallingDown" end))
2911
		table.insert(connections, humanoid.FreeFalling:connect(function(state) pose = "FreeFall" if state then soundFreeFalling:Play() else 
2912
2913
soundFreeFalling:Pause() end end))
2914
		table.insert(connections, humanoid.GettingUp:connect(function(state) pose = "GettingUp" if state then soundGettingUp:Play() else 
2915
2916
soundGettingUp:Pause() end end))
2917
		table.insert(connections, humanoid.PlatformStanding:connect(function() pose = "PlatformStanding" end))
2918
		table.insert(connections, humanoid.Seated:connect(function() pose = "Seated" end))
2919
		table.insert(connections, humanoid.Swimming:connect(function(speed) if speed > 0 then pose = "Swimming" else pose = "Standing" end end))
2920
		local previousRootPartCFrame = rootPart.CFrame
2921
		TaskScheduler.Start(function()
2922
			while active do
2923
				local totalTime = TaskScheduler.GetCurrentTime()
2924
				local stepTime = 1 / 60
2925
				if not PlayerControl.characterEnabled then
2926
					ResetCharacter()
2927
					break
2928
				end
2929
				torsoLight.Brightness = 0.5 + 0.15 * math.sin(totalTime * 0.75 * math.pi)
2930
				local featherfallEnabled = PlayerControl.IsFeatherfallEnabled()
2931
				local rootPartCFrame = rootPart.CFrame
2932
				if not jumpDebounce and UserInterface:IsKeyDown(Enum.KeyCode.Space) then
2933
					if humanoid.Sit then
2934
						humanoid.Sit = false
2935
					end
2936
					if IsStanding() then
2937
						jumpDebounce = true
2938
						pose = "Jumping"
2939
						rootPart.Velocity = Vector3.new(rootPart.Velocity.X, 50, rootPart.Velocity.Z)
2940
						torso.Velocity = Vector3.new(torso.Velocity.X, 50, torso.Velocity.Z)						
2941
						TaskScheduler.Schedule(1, function()
2942
							if pose == "Jumping" then
2943
								pose = "FreeFall"
2944
							end
2945
							jumpDebounce = false
2946
							humanoid.Jump = false
2947
						end)
2948
					end
2949
				end
2950
				local cameraCFrame = Camera.CoordinateFrame
2951
				local cameraDirection = cameraCFrame.lookVector
2952
				if flying then
2953
					if PlayerControl.rolling then
2954
						local rootPartCFrame = rootPart.CFrame
2955
						local speed = (rootPartCFrame - rootPartCFrame.p):pointToObjectSpace(rootPart.Velocity).Y
2956
						local decay = 0.5 ^ stepTime
2957
						if math.abs(speed) <= 50 then
2958
							PlayerControl.rollingAngle = (((PlayerControl.rollingAngle + 0.5) % 1 - 0.5) * decay) % 1
2959
							PlayerControl.rollingOffset = PlayerControl.rollingOffset * decay
2960
						else
2961
							PlayerControl.rollingAngle = (PlayerControl.rollingAngle + stepTime * speed * PlayerControl.rollingSpeed) % 1
2962
							PlayerControl.rollingOffset = (PlayerControl.rollingOffset + PlayerControl.rollingMaxOffset * (1 / decay - 1)) * decay
2963
						end
2964
						rootJoint.C0 = (CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0) * CFrame.Angles(PlayerControl.rollingAngle * 2 * math.pi, 0, 0)) * CFrame.new(0, -PlayerControl.rollingOffset, 0)
2965
					else
2966
						rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
2967
						PlayerControl.rollingAngle = 0
2968
						PlayerControl.rollingOffset = 0
2969
					end
2970
					rightShoulder.MaxVelocity = 0.5
2971
					leftShoulder.MaxVelocity = 0.5
2972
					rightShoulder.DesiredAngle = 0
2973
					leftShoulder.DesiredAngle = 0
2974
					rightHip.DesiredAngle = 0
2975
					leftHip.DesiredAngle = 0
2976
					bodyGyro.D = 500
2977
					bodyGyro.P = 1e6
2978
					bodyGyro.maxTorque = Vector3.new(1e6, 1e6, 1e6)
2979
					bodyVelocity.P = 1250
2980
					bodyVelocity.maxForce = Vector3.new(1e6, 1e6, 1e6)
2981
					local movementRight = 0
2982
					local movementForward = 0
2983
					local movementUp = 0
2984
					if UserInterface:IsKeyDown(Enum.KeyCode.A) and not UserInterface:IsKeyDown(Enum.KeyCode.D) then
2985
						movementRight = -1
2986
					elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
2987
						movementRight = 1
2988
					end
2989
					if UserInterface:IsKeyDown(Enum.KeyCode.W) then
2990
						movementUp = 0.2
2991
						if not UserInterface:IsKeyDown(Enum.KeyCode.S) then
2992
							movementForward = -1
2993
						end
2994
					elseif UserInterface:IsKeyDown(Enum.KeyCode.S) then
2995
						movementForward = 1
2996
					end
2997
					local movement = PlayerControl.fly_acceleration * cameraCFrame:vectorToWorldSpace(Vector3.new(movementRight, movementUp, movementForward))
2998
					local previousMomentum = flyingMomentum
2999
					local previousTilt = flyingTilt
3000
					flyingMomentum = movement + flyingMomentum * (1 - PlayerControl.fly_acceleration / PlayerControl.fly_speed)
3001
					flyingTilt = ((flyingMomentum * Vector3.new(1, 0, 1)).unit:Cross((previousMomentum * Vector3.new(1, 0, 1)).unit)).Y
3002
					if flyingTilt ~= flyingTilt or flyingTilt == math.huge then
3003
						flyingTilt = 0
3004
					end
3005
					local absoluteTilt = math.abs(flyingTilt)
3006
					if absoluteTilt > 0.06 or absoluteTilt < 0.0001 then
3007
						if math.abs(previousTilt) > 0.0001 then
3008
							flyingTilt = previousTilt * 0.9
3009
						else
3010
							flyingTilt = 0
3011
						end
3012
					else
3013
						flyingTilt = previousTilt * 0.77 + flyingTilt * 0.25
3014
					end
3015
					previousTilt = flyingTilt
3016
					if flyingMomentum.magnitude < 0.1 then
3017
						flyingMomentum = Vector3.new(0, 0, 0)
3018
--						bodyGyro.cframe = cameraCFrame
3019
					else
3020
						local momentumOrientation = CFrame.new(Vector3.new(0, 0, 0), flyingMomentum)
3021
						local tiltOrientation = CFrame.Angles(0, 0, -20 * flyingTilt)
3022
						bodyGyro.cframe = momentumOrientation * tiltOrientation * CFrame.Angles(-0.5 * math.pi * math.min(flyingMomentum.magnitude / PlayerControl.fly_speed, 1), 0, 0)
3023
					end
3024
					bodyVelocity.velocity = flyingMomentum + Vector3.new(0, 0.15695775618683547, 0)
3025
					rootPart.Velocity = flyingMomentum
3026
					previousMomentum = flyingMomentum
3027
				else
3028
					rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
3029
					PlayerControl.rollingAngle = 0
3030
					PlayerControl.rollingOffset = 0
3031
					bodyGyro.D = 3250
3032
					bodyGyro.P = 400000
3033
					bodyVelocity.P = 5000
3034
					local cameraDirection = cameraCFrame.lookVector
3035
					local walkDirection = Vector3.new(0, 0, 0)
3036
					local walkSpeed = 16
3037
					if UserInterface:IsKeyDown(Enum.KeyCode.W) then
3038
						if UserInterface:IsKeyDown(Enum.KeyCode.A) then
3039
							walkDirection = Vector3.new(cameraDirection.X + cameraDirection.Z, 0, cameraDirection.Z - cameraDirection.X).unit
3040
						elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
3041
							walkDirection = Vector3.new(cameraDirection.X - cameraDirection.Z, 0, cameraDirection.Z + cameraDirection.X).unit
3042
						else
3043
							walkDirection = Vector3.new(cameraDirection.X, 0, cameraDirection.Z).unit
3044
						end
3045
					elseif UserInterface:IsKeyDown(Enum.KeyCode.S) then
3046
						if UserInterface:IsKeyDown(Enum.KeyCode.A) then
3047
							walkDirection = Vector3.new(-cameraDirection.X + cameraDirection.Z, 0, -cameraDirection.Z - cameraDirection.X).unit
3048
						elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
3049
							walkDirection = Vector3.new(-cameraDirection.X - cameraDirection.Z, 0, -cameraDirection.Z + cameraDirection.X).unit
3050
						else
3051
							walkDirection = Vector3.new(-cameraDirection.X, 0, -cameraDirection.Z).unit
3052
						end
3053
					elseif UserInterface:IsKeyDown(Enum.KeyCode.A) then
3054
						walkDirection = Vector3.new(cameraDirection.Z, 0, -cameraDirection.X).unit
3055
					elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
3056
						walkDirection = Vector3.new(-cameraDirection.Z, 0, cameraDirection.X).unit
3057
					else
3058
						walkSpeed = 0
3059
					end
3060
					if walkSpeed ~= previousWalkSpeed then
3061
						if walkSpeed > 0 then
3062
							soundRunning:Play()
3063
						else
3064
							soundRunning:Pause()
3065
						end
3066
					end
3067
					if walkSpeed > 0 then
3068
						if pose ~= "Jumping" then
3069
							if IsStanding() then
3070
								pose = "Running"
3071
							else
3072
								pose = "FreeFall"
3073
							end
3074
						end
3075
						bodyGyro.cframe = CFrame.new(Vector3.new(), walkDirection)
3076
						bodyGyro.maxTorque = Vector3.new(1000000000, 1000000000, 1000000000)
3077
						bodyVelocity.maxForce = Vector3.new(1000000, maxForceY, 1000000)
3078
					else
3079
						if pose ~= "Jumping" then
3080
							if IsStanding() then
3081
								pose = "Standing"
3082
							else
3083
								pose = "FreeFall"
3084
							end
3085
						end
3086
						-- TODO: find and fix bug that causes torso to rotate back to some angle
3087
						bodyGyro.maxTorque = Vector3.new(1000000000, 1000000000, 1000000000) -- Vector3.new(1000000000, 0, 1000000000)
3088
						if PlayerControl.pushable then
3089
							bodyVelocity.maxForce = Vector3.new(0, 0, 0)
3090
						else
3091
							bodyVelocity.maxForce = Vector3.new(1000000, 0, 1000000)
3092
						end
3093
					end
3094
					if featherfallEnabled then
3095
						local velocity = rootPart.Velocity
3096
						if velocity.Y > 50 then
3097
							rootPart.Velocity = Vector3.new(velocity.X, 50, velocity.Z)
3098
						elseif velocity.Y < -50 then
3099
							rootPart.Velocity = Vector3.new(velocity.X, -50, velocity.Z)
3100
						end
3101
						local distanceVector = rootPartCFrame.p - previousRootPartCFrame.p
3102
						local offsetX, offsetY, offsetZ = distanceVector.X, distanceVector.Y, distanceVector.Z
3103
						local MAX_MOVEMENT = 50 * 0.03333333507180214
3104
						if offsetX > MAX_MOVEMENT then
3105
							offsetX = MAX_MOVEMENT
3106
						elseif offsetX < -MAX_MOVEMENT then
3107
							offsetX = -MAX_MOVEMENT
3108
						end
3109
						if offsetY > MAX_MOVEMENT then
3110
							offsetY = MAX_MOVEMENT
3111
						elseif offsetY < -MAX_MOVEMENT then
3112
							offsetY = -MAX_MOVEMENT
3113
						end
3114
						if offsetZ > MAX_MOVEMENT then
3115
							offsetZ = MAX_MOVEMENT
3116
						elseif offsetZ < -MAX_MOVEMENT then
3117
							offsetZ = -MAX_MOVEMENT
3118
						end
3119
						local offset = Vector3.new(offsetX, offsetY, offsetZ)
3120
						if offset ~= distanceVector then
3121
							rootPartCFrame = previousRootPartCFrame + offset
3122
							--rootPart.CFrame = rootPartCFrame
3123
						end
3124
					end
3125
					local walkingVelocity = walkDirection * walkSpeed
3126
					bodyVelocity.velocity = walkingVelocity
3127
					if not jumpDebounce and math.abs(rootPart.Velocity.Y) <= 0.1 then
3128
						rootPart.Velocity = Vector3.new(walkingVelocity.X, rootPart.Velocity.Y, walkingVelocity.Z)
3129
					end
3130
					previousWalkSpeed = walkSpeed
3131
					if pose == "Jumping" or jumpDebounce then
3132
						rightShoulder.MaxVelocity = 0.5
3133
						leftShoulder.MaxVelocity = 0.5
3134
						rightShoulder.DesiredAngle = 3.14
3135
						leftShoulder.DesiredAngle = -3.14
3136
						rightHip.DesiredAngle = 0
3137
						leftHip.DesiredAngle = 0
3138
					elseif pose == "FreeFall" then
3139
						rightShoulder.MaxVelocity = 0.5
3140
						leftShoulder.MaxVelocity = 0.5
3141
						rightShoulder.DesiredAngle = 3.14
3142
						leftShoulder.DesiredAngle = -3.14
3143
						rightHip.DesiredAngle = 0
3144
						leftHip.DesiredAngle = 0
3145
					elseif pose == "Seated" then
3146
						rightShoulder.MaxVelocity = 0.15
3147
						leftShoulder.MaxVelocity = 0.15
3148
						rightShoulder.DesiredAngle = 3.14 / 2
3149
						leftShoulder.DesiredAngle = -3.14 / 2
3150
						rightHip.DesiredAngle = 3.14 / 2
3151
						leftHip.DesiredAngle = -3.14 / 2
3152
					else
3153
						local climbFudge = 0
3154
						local amplitude
3155
						local frequency
3156
						if pose == "Running" then
3157
							rightShoulder.MaxVelocity = 0.15
3158
							leftShoulder.MaxVelocity = 0.15
3159
							amplitude = 1
3160
							frequency = 9
3161
						elseif (pose == "Climbing") then
3162
							rightShoulder.MaxVelocity = 0.5 
3163
							leftShoulder.MaxVelocity = 0.5
3164
							amplitude = 1
3165
							frequency = 9
3166
							climbFudge = 3.14
3167
						else
3168
							amplitude = 0.1
3169
							frequency = 1
3170
						end
3171
						local desiredAngle = amplitude * math.sin(totalTime * frequency)
3172
						rightShoulder.DesiredAngle = desiredAngle + climbFudge
3173
						leftShoulder.DesiredAngle = desiredAngle - climbFudge
3174
						rightHip.DesiredAngle = -desiredAngle
3175
						leftHip.DesiredAngle = -desiredAngle
3176
					end
3177
				end
3178
				previousRootPartCFrame = rootPartCFrame
3179
				RunService.RenderStepped:wait()
3180
			end
3181
			if model.Parent ~= nil then
3182
				model.Parent = nil
3183
			end
3184
			PlayerControl.CreateCharacter()
3185
		end)
3186
		humanoid.Health = 100
3187
		character = model
3188
		chatAdornee = head
3189
	elseif characterMode == "pyramid" then
3190
		if PlayerControl.characterEnabled then
3191
			Camera.CameraType = "Fixed"
3192
			PyramidCharacter.camera_distance = (Camera.Focus.p - Camera.CoordinateFrame.p).magnitude
3193
			PyramidCharacter.camera_position = Camera.Focus.p
3194
			PyramidCharacter.Teleport(Camera.Focus.p)
3195
			PyramidCharacter.visible = true
3196
			Player.Character = nil
3197
		else
3198
			PyramidCharacter.visible = false
3199
		end
3200
	end
3201
end
3202
function PlayerControl.GetCharacter()
3203
	return character
3204
end
3205
function PlayerControl.GetHead()
3206
	local characterMode = PlayerControl.characterMode
3207
	if characterMode == "normal" then
3208
		return head
3209
	elseif characterMode == "pyramid" then
3210
		return PyramidCharacter.core
3211
	end
3212
end
3213
function PlayerControl.GetHumanoid()
3214
	return humanoid
3215
end
3216
function PlayerControl.GetRootPart()
3217
	return rootPart
3218
end
3219
function PlayerControl.GetTorso()
3220
	return torso
3221
end
3222
function PlayerControl.IsEnabled()
3223
	return PlayerControl.characterEnabled
3224
end
3225
function PlayerControl.IsFeatherfallEnabled()
3226
	return PlayerControl.featherfallEnabled
3227
end
3228
function PlayerControl.IsPushable()
3229
	return PlayerControl.pushable
3230
end
3231
function PlayerControl.IsRolling()
3232
	return PlayerControl.rolling
3233
end
3234
function PlayerControl.ResetCharacter()
3235
	if character and character.Parent then
3236
		character.Parent = nil
3237
	end
3238
	PyramidCharacter.visible = false
3239
end
3240
function PlayerControl.SetEnabled(state, no_animation)
3241
	state = not not state
3242
	if state ~= PlayerControl.characterEnabled then
3243
		PlayerControl.characterEnabled = state
3244
		local characterMode = PlayerControl.characterMode
3245
		if characterMode == "normal" then
3246
			local torso = PlayerControl.GetRootPart()
3247
			local rootPart = PlayerControl.GetRootPart()
3248
			if rootPart then
3249
				if PlayerControl.characterEnabled then
3250
					local torso_cframe = Camera.Focus:toWorldSpace(PlayerControl.hide_torso_object_cframe)
3251
					PlayerControl.torso_cframe = torso_cframe
3252
					torso.CFrame = torso_cframe
3253
					rootPart.CFrame = torso_cframe
3254
				else
3255
					PlayerControl.hide_torso_object_cframe = Camera.Focus:toObjectSpace(rootPart.CFrame)
3256
				end
3257
			else
3258
				PlayerControl.torso_cframe = Camera.Focus
3259
			end
3260
			if PlayerControl.characterEnabled then
3261
				PlayerControl.CreateCharacter()
3262
				RunService.Stepped:wait()
3263
				coroutine.yield()
3264
				if not no_animation then
3265
					GraphicalEffects.CrystalRing({base_part = PlayerControl.GetTorso(), crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
3266
				end		
3267
			else
3268
				Player.Character = nil
3269
				Camera.CameraType = "Fixed"
3270
				if not no_animation then
3271
					GraphicalEffects.CrystalRing({position = PlayerControl.GetTorso().Position, crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
3272
				end
3273
			end
3274
		else
3275
			if state then
3276
				PlayerControl.CreateCharacter()
3277
				RunService.Stepped:wait()
3278
				coroutine.yield()
3279
				if not no_animation then
3280
					GraphicalEffects.CrystalRing({base_part = PyramidCharacter.core, crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
3281
				end
3282
			else
3283
				PyramidCharacter.visible = false
3284
				if not no_animation then
3285
					GraphicalEffects.CrystalRing({position = PyramidCharacter.core.Position, crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
3286
				end
3287
			end
3288
		end
3289
	end
3290
end
3291
function PlayerControl.SetFeatherfallEnabled(state)
3292
	state = not not state
3293
	if state ~= PlayerControl.featherfallEnabled then
3294
		PlayerControl.featherfallEnabled = state
3295
		if state then
3296
			Logger.print("Info", "Featherfall enabled in PlayerControl")
3297
		else
3298
			Logger.print("Info", "Featherfall disabled in PlayerControl")
3299
		end
3300
	end
3301
end
3302
function PlayerControl.SetPushable(state)
3303
	state = not not state
3304
	if state ~= PlayerControl.pushable then
3305
		PlayerControl.pushable = state
3306
		if state then
3307
			Logger.print("Info", "Pushing enabled in PlayerControl")
3308
		else
3309
			Logger.print("Info", "Pushing disabled in PlayerControl")
3310
		end
3311
	end
3312
end
3313
function PlayerControl.SetRolling(state)
3314
	state = not not state
3315
	if state ~= PlayerControl.rolling then
3316
		PlayerControl.rolling = state
3317
		if state then
3318
			Logger.print("Info", "Rolling fly mode enabled in PlayerControl")
3319
		else
3320
			Logger.print("Info", "Rolling fly mode disabled in PlayerControl")
3321
		end
3322
	end
3323
end
3324
function PlayerControl.StartFlying()
3325
	PlayerControl.fly_speed = PlayerControl.fly_basespeed
3326
	if torso then
3327
		flyingMomentum = torso.Velocity + torso.CFrame.lookVector * 3 + Vector3.new(0, 10, 0)
3328
	else
3329
		flyingMomentum = Vector3.new()
3330
	end
3331
	flyingTilt = 0
3332
	flying = true
3333
end
3334
function PlayerControl.StopFlying()
3335
	if bodyGyro.cframe then
3336
		local lookVector = bodyGyro.cframe.lookVector
3337
		if lookVector.X ~= 0 or lookVector.Z ~= 0 then
3338
			bodyGyro.cframe = CFrame.new(Vector3.new(), Vector3.new(lookVector.X, 0, lookVector.Z))
3339
		end
3340
	end
3341
	flying = false
3342
end
3343
local previousTime = 0
3344
3345
ControllerCommands = {};
3346
3347
ControllerCommands = {};
3348
3349
ControllerCommands.BALEFIRE_SPEED = 40
3350
function ControllerCommands.BalefireAtMouse()
3351
        local head = chatAdornee
3352
        if head then
3353
                local target = Mouse.Hit.p
3354
                local origin = head.Position
3355
                local direction = (target - origin).unit
3356
                local explosionCount = 0
3357
                local animation_frame = 0
3358
                local magic_circle_position = origin + direction * 4
3359
                local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
3360
                local magic_circle_part = Instance.new("Part")
3361
                local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
3362
                local magic_circle_light = Instance.new("PointLight", magic_circle_part)
3363
                local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
3364
                local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
3365
                magic_circle_part.Anchored = true
3366
                magic_circle_part.Archivable = false
3367
                magic_circle_part.BottomSurface = "Smooth"
3368
                magic_circle_part.CanCollide = false
3369
                magic_circle_part.CFrame = magic_circle_cframe
3370
                magic_circle_part.FormFactor = "Custom"
3371
                magic_circle_part.Locked = true
3372
                magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
3373
                magic_circle_part.TopSurface = "Smooth"
3374
                magic_circle_part.Transparency = 1
3375
                magic_circle_mesh.Scale = Vector3.new(60, 60, 0)
3376
                magic_circle_light.Color = Color3.new(1, 0.5, 1)
3377
                magic_circle_light.Range = 16
3378
                magic_circle_light.Shadows = true
3379
                magic_circle_decal_back.Face = "Back"
3380
                magic_circle_decal_back.Texture = "rbxassetid://122610943"
3381
                magic_circle_decal_front.Face = "Front"
3382
                magic_circle_decal_front.Texture = "rbxassetid://122610943"
3383
                local function NextExplosion()
3384
                        explosionCount = explosionCount + 1
3385
                        Instance.new("Explosion", Workspace).Position = origin + direction * (explosionCount * 8 + 4)
3386
                end
3387
                local function AnimateMagicCircle()
3388
                        animation_frame = animation_frame + 1
3389
                        local transparency = (animation_frame / 40) ^ 3
3390
                        if animation_frame == 40 then
3391
                                pcall(Game.Destroy, magic_circle_part)
3392
                        else
3393
                                if magic_circle_part.Parent ~= Workspace then
3394
                                        pcall(Utility.SetProperty, magic_circle_part, "Parent", Workspace)
3395
                                end
3396
                                head = PlayerControl.GetHead()
3397
                                if head then
3398
                                        magic_circle_position = head.Position + direction * 4
3399
                                end
3400
                                magic_circle_part.CFrame = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0,
3401
 
3402
math.tau * animation_frame / 40 * 1.5)
3403
                                magic_circle_light.Brightness = 1 - transparency
3404
                                magic_circle_decal_back.Transparency = transparency
3405
                                magic_circle_decal_front.Transparency = transparency
3406
                        end
3407
                end
3408
                magic_circle_part.Parent = Workspace
3409
                for i = 1, 40 do
3410
                        Delay((i - 1) / ControllerCommands.BALEFIRE_SPEED, NextExplosion)
3411
                        Delay((i - 1) / 30, AnimateMagicCircle)
3412
                end
3413
                for i = 1, 20 do
3414
                        Delay((i - 1) / ControllerCommands.BALEFIRE_SPEED, NextExplosion)
3415
                end
3416
        end
3417
end
3418
function ControllerCommands.ControlRandomDummy()
3419
        local dummies = {}
3420
        local numDummies = 0
3421
        for _, character in ipairs(Workspace:GetChildren()) do
3422
                local name = tostring(character)
3423
                if name == "???" or name == "Dummy" then
3424
                        local head, humanoid
3425
                        for _, child in ipairs(character:GetChildren()) do
3426
                                local className = child.ClassName
3427
                                if className == "Part" and tostring(child) == "Head" then
3428
                                        head = child
3429
                                        if humanoid then
3430
                                                break
3431
                                        end
3432
                                elseif className == "Humanoid" then
3433
                                        if child.Health > 0 then
3434
                                                humanoid = child
3435
                                                if head then
3436
                                                        break
3437
                                                end
3438
                                        else
3439
                                                break
3440
                                        end
3441
                                end
3442
                        end
3443
                        if head and humanoid then
3444
                                numDummies = numDummies + 1
3445
                                dummies[numDummies] = {character, head, humanoid}
3446
                        end
3447
                end
3448
        end
3449
        if numDummies > 0 then
3450
                local dummy = dummies[math.random(numDummies)]
3451
                Player.Character = dummy[1]
3452
                chatAdornee = dummy[2]
3453
                Camera.CameraSubject = dummy[3]
3454
                Camera.CameraType = "Track"
3455
        end
3456
end
3457
function ControllerCommands.Decalify(textures, exclusion)
3458
        local objects = Workspace:GetChildren()
3459
        for _, object in ipairs(objects) do
3460
                if not exclusion[object] then
3461
                        for _, child in ipairs(object:GetChildren()) do
3462
                                objects[#objects + 1] = child
3463
                        end
3464
                        if object:IsA("BasePart") then
3465
                                local texture = textures[math.random(#textures)]
3466
                                local face_left = Instance.new("Decal", object)
3467
                                face_left.Face = Enum.NormalId.Left
3468
                                face_left.Texture = texture
3469
                                local face_right = Instance.new("Decal", object)
3470
                                face_right.Face = Enum.NormalId.Right
3471
                                face_right.Texture = texture
3472
                                local face_bottom = Instance.new("Decal", object)
3473
                                face_bottom.Face = Enum.NormalId.Bottom
3474
                                face_bottom.Texture = texture
3475
                                local face_top = Instance.new("Decal", object)
3476
                                face_top.Face = Enum.NormalId.Top
3477
                                face_top.Texture = texture
3478
                                local face_front = Instance.new("Decal", object)
3479
                                face_front.Face = Enum.NormalId.Front
3480
                                face_front.Texture = texture
3481
                                local face_back = Instance.new("Decal", object)
3482
                                face_back.Face = Enum.NormalId.Back
3483
                                face_back.Texture = texture
3484
                        end
3485
                end
3486
        end
3487
end
3488
3489
function ControllerCommands.ExplodeAtMouse()
3490
        local explosion = Instance.new("Explosion")
3491
        explosion.Position = Mouse.Hit.p
3492
        explosion.Parent = Workspace
3493
end
3494
function ControllerCommands.LaserAtMouse()
3495
        GraphicalEffects.ShootLaserOfDeath(Mouse.Hit.p)
3496
end
3497
function ControllerCommands.BigLaser(target)
3498
        GraphicalEffects.ShootLaserOfDeath(target, {brickcolor = BrickColor.new("New Yeller"), duration = 80, fragmentation_size = 6,laser_scale = 30, light_color = Color3.new(1, 0.5, 0), magic_circle_image = "rbxassetid://126561317", magic_circle_scale = 1.5, sound_volume = 1,special_effects = BrickColor.new("Deep orange"), stay = 2})
3499
end
3500
function ControllerCommands.BigLaserAtMouse()
3501
        ControllerCommands.BigLaser(Mouse.Hit.p)
3502
end
3503
function ControllerCommands.ShootMissile(targetPart, pointOnPart, direction)
3504
        GraphicalEffects.ShootMissile(targetPart, pointOnPart, direction)
3505
end
3506
function ControllerCommands.ShootMissileAtMouse(amount, spread, delayTime)
3507
        local exclusionList = {}
3508
        local playerHead = PlayerControl.GetHead()
3509
        local playerTorso = PlayerControl.GetTorso()
3510
        if playerHead and playerTorso then
3511
                exclusionList[playerTorso] = true
3512
                local humanoid, torso = Utility.FindHumanoidClosestToRay(Mouse.UnitRay, exclusionList)
3513
                local targetPart, pointOnPart
3514
                if humanoid and torso then
3515
                        targetPart, pointOnPart = torso, Vector3.new()
3516
                else
3517
                        local target = Mouse.Target
3518
                        if target then
3519
                                targetPart, pointOnPart = target, target.CFrame:pointToObjectSpace(Mouse.Hit.p)
3520
                        else
3521
                                return
3522
                        end
3523
                end
3524
                if targetPart then
3525
                        local direction = (Mouse.Hit.p - playerHead.Position).unit
3526
                        delayTime = delayTime or 0
3527
                        for index = 1, amount do
3528
                                local angles = math.tau * (index - 0.5) * spread / amount * Vector3.new(math.random() - 0.5, math.random() - 0.5,math.random() - 0.5).unit
3529
                                TaskScheduler.Schedule(delayTime * (index - 1), ControllerCommands.ShootMissile, targetPart, pointOnPart, CFrame.Angles(angles.X, angles.Y, angles.Z) * direction)
3530
                        end
3531
                end
3532
        end
3533
end
3534
function ControllerCommands.ShootMissileAroundMouse(amount, offset, delayTime)
3535
        local exclusionList = {}
3536
        local playerHead = PlayerControl.GetHead()
3537
        local playerTorso = PlayerControl.GetTorso()
3538
        if playerHead and playerTorso then
3539
                exclusionList[playerTorso] = true
3540
                local humanoid, torso = Utility.FindHumanoidClosestToRay(Mouse.UnitRay, exclusionList)
3541
                local targetPart, pointOnPart
3542
                if humanoid and torso then
3543
                        targetPart, pointOnPart = torso, Vector3.new()
3544
                else
3545
                        local target = Mouse.Target
3546
                        if target then
3547
                                targetPart, pointOnPart = target, target.CFrame:pointToObjectSpace(Mouse.Hit.p)
3548
                        else
3549
                                return
3550
                        end
3551
                end
3552
                if targetPart then
3553
                        delayTime = delayTime or 0
3554
                        local index = 1
3555
                        local targetPoint = targetPart.CFrame * pointOnPart
3556
                        local rotation_offset_angles = math.tau * Vector3.new(math.random() - 0.5, math.random() - 0.5, 0).unit
3557
                        local rotation_offset = CFrame.Angles(rotation_offset_angles.x, rotation_offset_angles.y, 0)
3558
                        local angle_x = 0
3559
                        local angle_x_step = math.tau / math.phi
3560
                        for i = 1, 8 * amount do
3561
                                angle_x = angle_x + angle_x_step
3562
                                local direction = rotation_offset * (CFrame.Angles(0, math.tau * index / amount, 0) * CFrame.Angles(angle_x, 0,0).lookVector)
3563
                                local blocked = Workspace:FindPartOnRay(Ray.new(targetPoint, direction * offset), targetPart.Parent)
3564
                                if not blocked then
3565
                                        local p0, p1, p2, p3 = targetPart, pointOnPart, direction, offset; GraphicalEffects.ShootMissile(p0, p1, p2, function() return p0 end, p3, true)
3566
                                        index = index + 1
3567
                                        if index > amount then
3568
                                                break
3569
                                        end
3570
                                end
3571
                        end
3572
                end
3573
        end
3574
end
3575
3576
function ControllerCommands.HugeExplosionOfDoom(position)
3577
        local connections = {}
3578
        local parts = {}
3579
        local cframe = CFrame.new(position)
3580
        local function ExplosionHit(part)
3581
                if part:GetMass() < 10000 and part.Parent ~= Camera then
3582
                        parts[part] = true
3583
                        part.Anchored = true
3584
                        part:BreakJoints()
3585
                        part.BrickColor = BrickColor.new("Instituational white")
3586
                end
3587
        end
3588
        for i = 1, 4 do
3589
                local quantity = 0.5 * i * (1 + i)
3590
                local fraction = math.tau / quantity
3591
                for x = 1, quantity do
3592
                        for y = 1, quantity do
3593
                                local explosion = Instance.new("Explosion")
3594
                                connections[#connections + 1] = explosion.Hit:connect(ExplosionHit)
3595
                                explosion.BlastRadius = 5
3596
                                explosion.Position = cframe * (CFrame.Angles(fraction * x, fraction * y, 0) * Vector3.new((i - 1) * 6, 0, 0))
3597
                                explosion.Parent = Workspace
3598
                        end
3599
                end
3600
                wait(0.075)
3601
        end
3602
        for part in pairs(parts) do
3603
                for _, child in ipairs(part:GetChildren()) do
3604
                        if child:IsA("BodyMover") then
3605
                                child:Destroy()
3606
                        end
3607
                end
3608
                local mass = part:GetMass()
3609
                local velocity = CFrame.Angles(math.tau * math.random(), math.tau * math.random(), 0) * Vector3.new(25, 0, 0)
3610
                local bodythrust = Instance.new("BodyThrust")
3611
                bodythrust.force = mass * -velocity
3612
                bodythrust.Parent = part
3613
                local bodyforce = Instance.new("BodyForce")
3614
                bodyforce.force = mass * Vector3.new(0, 196.2, 0)
3615
                bodyforce.Parent = part
3616
                part.Anchored = false
3617
                part.Reflectance = 1
3618
                part.RotVelocity = math.tau * Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5)
3619
                part.Transparency = 0.5
3620
                part.Velocity = (part.CFrame - part.Position) * velocity
3621
        end
3622
        for _, connection in ipairs(connections) do
3623
                connection:disconnect()
3624
        end
3625
        for i = 0, 99 do
3626
                Delay(i / 10, function()
3627
                        for part in pairs(parts) do
3628
                                local new_transparency = 0.5 * (1 + i / 50)
3629
                                part.Reflectance = 0.98 * part.Reflectance
3630
                                if new_transparency > part.Transparency then
3631
                                        part.Transparency = new_transparency
3632
                                end
3633
                        end
3634
                end)
3635
        end
3636
        Delay(10, function()
3637
                for part in pairs(parts) do
3638
                        pcall(part.Destroy, part)
3639
                end
3640
        end)
3641
end
3642
function ControllerCommands.HugeExplosionOfDoomAtMouse()
3643
        ControllerCommands.HugeExplosionOfDoom(Mouse.Hit.p)
3644
end
3645
3646
function ControllerCommands.SpaceHyperBeam(asd)
3647
        GraphicalEffects.SpaceHyperBeam(asd)
3648
end
3649
function ControllerCommands.SpaceHyperBeamAtMouse()
3650
        ControllerCommands.SpaceHyperBeam(Mouse.Hit.p)
3651
end
3652
function ControllerCommands.ConcentratedSpaceHyperBeamAtMouse()
3653
        local p = Mouse.Hit.p; for i = 1, 50 do GraphicalEffects.SpaceHyperBeam(p) end
3654
end
3655
3656
function ControllerCommands.TeleportCharacterToMouse()
3657
        if PlayerControl.IsEnabled() then
3658
                local torso = PlayerControl.GetTorso()
3659
                if torso then
3660
                        local pos = Mouse.Hit.p + Vector3.new(0, 5, 0)
3661
                        torso.CFrame = CFrame.new(pos, pos + torso.CFrame.lookVector)
3662
                end
3663
        else
3664
                local new_focus_position = Mouse.Hit.p
3665
                local direction_vector = Camera.CoordinateFrame.lookVector
3666
                local new_focus = CFrame.new(new_focus_position, new_focus_position + direction_vector)
3667
                Camera.CoordinateFrame = new_focus * CFrame.new(0, 0, 25)
3668
                Camera.Focus = new_focus
3669
        end
3670
end
3671
3672
AdvancedGUI = {};
3673
3674
if not AdvancedGUI.GUI_BASE_COLOR then
3675
	AdvancedGUI.GUI_BASE_COLOR = Color3.new(0, 0, 0)
3676
end
3677
function AdvancedGUI.GenerateChatColor(speakerName)
3678
	local chatColor = ChatColor.Get(speakerName).Color
3679
	local brightness = chatColor.r + chatColor.g + chatColor.b
3680
	if brightness < 1.5 then
3681
		chatColor = Color3.new(math.min(1, 0.4 + chatColor.r), math.min(1, 0.4 + chatColor.g), math.min(1, 0.4 + chatColor.b))
3682
	else
3683
		chatColor = Color3.new(math.min(1, 0.05 + chatColor.r), math.min(1, 0.05 + chatColor.g), math.min(1, 0.05 + chatColor.b))
3684
	end
3685
	return chatColor
3686
end
3687
GuiBase = {}
3688
GuiBase.__index = GuiBase
3689
function GuiBase:new(data)
3690
	local instance = setmetatable({}, self)
3691
	instance:Init(data)
3692
	return instance
3693
end
3694
function GuiBase:Destroy()
3695
	if self.parent then
3696
		self.parent.children[self] = nil
3697
	end
3698
	for child in pairs(self.children) do
3699
		child:Destroy()
3700
	end
3701
	self.m_base_instance:Destroy()
3702
end
3703
function GuiBase:GetContentInstance(child)
3704
	return self.m_base_instance
3705
end
3706
function GuiBase:Init()
3707
	self.children = {}
3708
end
3709
function GuiBase:IsA(className)
3710
	return className == "GuiBase"
3711
end
3712
function GuiBase:SetParent(parent)
3713
	if parent ~= self.parent then
3714
		if self.parent then
3715
			self.parent.children[self] = nil
3716
		end
3717
		self.parent = parent
3718
		if parent then
3719
			parent.children[self] = true
3720
			self.m_base_instance.Parent = parent:GetContentInstance()
3721
		else
3722
			self.m_base_instance.Parent = nil
3723
		end
3724
	end
3725
end
3726
GuiObject = setmetatable({}, GuiBase)
3727
GuiObject.__index = GuiObject
3728
function GuiObject:Destroy()
3729
	self.DragBegin:disconnect()
3730
	self.DragMove:disconnect()
3731
	self.DragStopped:disconnect()
3732
	self.MouseButton1Click:disconnect()
3733
	self.MouseButton1Down:disconnect()
3734
	self.MouseButton1Up:disconnect()
3735
	self.MouseButton2Down:disconnect()
3736
	self.MouseButton2Up:disconnect()
3737
	self.MouseEnter:disconnect()
3738
	self.MouseLeave:disconnect()
3739
	GuiBase.Destroy(self)
3740
end
3741
function GuiObject:GetAbsolutePosition()
3742
	return self.m_base_instance.AbsolutePosition
3743
end
3744
function GuiObject:GetAbsoluteSize()
3745
	return self.m_base_instance.AbsoluteSize
3746
end
3747
function GuiObject:GetPosition()
3748
	return self.position
3749
end
3750
function GuiObject:GetSize()
3751
	return self.size
3752
end
3753
function GuiObject:Init()
3754
	GuiBase.Init(self)
3755
	self.mouseDown = false
3756
	self.mouseOver = false
3757
	self.DragBegin = RbxUtility.CreateSignal()
3758
	self.DragMove = RbxUtility.CreateSignal()
3759
	self.DragStopped = RbxUtility.CreateSignal()
3760
	self.MouseButton1Click = RbxUtility.CreateSignal()
3761
	self.MouseButton1Down = RbxUtility.CreateSignal()
3762
	self.MouseButton1Up = RbxUtility.CreateSignal()
3763
	self.MouseButton2Down = RbxUtility.CreateSignal()
3764
	self.MouseButton2Up = RbxUtility.CreateSignal()
3765
	self.MouseEnter = RbxUtility.CreateSignal()
3766
	self.MouseLeave = RbxUtility.CreateSignal()
3767
end
3768
function GuiObject:IsA(className)
3769
	return className == "GuiObject" or GuiBase.IsA(self, className)
3770
end
3771
function GuiObject:SetActive(active)
3772
	if active ~= self.active then
3773
		self.active = active
3774
	end
3775
end
3776
function GuiObject:SetBackgroundTransparency(backgroundTransparency)
3777
	if backgroundTransparency ~= self.backgroundTransparency then
3778
		self.backgroundTransparency = backgroundTransparency
3779
		self.m_base_instance.BackgroundTransparency = backgroundTransparency
3780
	end
3781
end
3782
function GuiObject:SetColor(color)
3783
	if color ~= self.color then
3784
		self.color = color
3785
		self.m_base_instance.BackgroundColor3 = color
3786
	end
3787
end
3788
function GuiObject:SetPosition(position)
3789
	if position ~= self.position then
3790
		self.position = position
3791
		self.m_base_instance.Position = position
3792
	end
3793
end
3794
function GuiObject:SetSize(size)
3795
	if size ~= self.size then
3796
		self.size = size
3797
		self.m_base_instance.Size = size
3798
	end
3799
end
3800
function GuiObject:SetVisible(visible)
3801
	if visible ~= self.visible then
3802
		self.visible = visible
3803
		self.m_base_instance.Visible = visible
3804
	end
3805
end
3806
function GuiObject:SetZIndex(zIndex)
3807
	local stack = {self.m_base_instance}
3808
	repeat
3809
		local object = stack[#stack]
3810
		stack[#stack] = nil
3811
		for _, child in ipairs(object:GetChildren()) do
3812
			stack[#stack + 1] = child
3813
		end
3814
		object.ZIndex = zIndex
3815
	until #stack == 0
3816
end
3817
GuiServiceClass = setmetatable({}, GuiBase)
3818
GuiServiceClass.__index = GuiServiceClass
3819
function GuiServiceClass:CreateTextArea(text, font, fontSize, textColor3, textXAlignment, textYAlignment, maxWidth, minWidth)
3820
	local totalHeight = 0
3821
	local frame = Instance.new("Frame")
3822
	frame.BackgroundTransparency = 1
3823
	local label = Instance.new("TextLabel")
3824
	label.BackgroundTransparency = 1
3825
	label.Font = font
3826
	label.FontSize = fontSize
3827
	label.TextColor3 = textColor3
3828
	label.TextTransparency = 1
3829
	label.TextWrapped = true
3830
	label.TextXAlignment = textXAlignment
3831
	label.TextYAlignment = textYAlignment
3832
	label.Parent = self.guiFrame
3833
	local index = 1
3834
	while true do
3835
		local length = #text - index + 1
3836
		if length > 1024 then
3837
			length = 1024
3838
			local textBlock = string.sub(text, index, index + length - 1)
3839
			label.Text = textBlock
3840
			local height = 0
3841
			local width = maxWidth
3842
			repeat
3843
				height = height + 20
3844
				label.Size = UDim2.new(0, width, 0, height)
3845
			until label.TextFits
3846
			repeat
3847
				height = height - 1
3848
				label.Size = UDim2.new(0, width, 0, height)
3849
			until not label.TextFits
3850
			repeat
3851
				length = length - 10
3852
				label.Text = string.sub(text, index, index + length - 1)
3853
			until label.TextFits
3854
			repeat
3855
				length = length + 1
3856
				label.Text = string.sub(text, index, index + length - 1)
3857
			until not label.TextFits
3858
			local overflowCharacter = string.sub(text, index + length - 1, index + length - 1)
3859
			length = length - 1
3860
			label.Text = string.sub(text, index, index + length - 1)
3861
			if overflowCharacter == "\n" then
3862
				index = index + 1
3863
			end
3864
			repeat
3865
				height = height - 1
3866
				label.Size = UDim2.new(0, width, 0, height)
3867
			until not label.TextFits
3868
			height = height + 1
3869
			local blockLabel = label:Clone()
3870
			blockLabel.Position = UDim2.new(0, 0, 0, totalHeight)
3871
			blockLabel.Size = UDim2.new(1, 0, 0, height)
3872
			blockLabel.Parent = frame
3873
			totalHeight = totalHeight + height
3874
			index = index + length
3875
		else
3876
			local textBlock = string.sub(text, index)
3877
			label.Text = textBlock
3878
			local height = 0
3879
			local width = maxWidth
3880
			repeat
3881
				height = height + 20
3882
				label.Size = UDim2.new(0, width, 0, height)
3883
			until label.TextFits
3884
			repeat
3885
				height = height - 1
3886
				label.Size = UDim2.new(0, width, 0, height)
3887
			until not label.TextFits
3888
			height = height + 1
3889
			if index == 1 then
3890
				repeat
3891
					width =  width - 10
3892
					label.Size = UDim2.new(0, width, 0, height)
3893
				until width < minWidth or not label.TextFits
3894
				width = math.max(width, minWidth - 1)
3895
				repeat
3896
					width =  width + 1
3897
					label.Size = UDim2.new(0, width, 0, height)
3898
				until label.TextFits
3899
			end
3900
			local blockLabel = label:Clone()
3901
			blockLabel.Position = UDim2.new(0, 0, 0, totalHeight)
3902
			blockLabel.Size = UDim2.new(1, 0, 0, height)
3903
			blockLabel.Parent = frame
3904
			label:Destroy()
3905
			frame.Size = UDim2.new(0, width, 0, totalHeight + height)
3906
			return frame
3907
		end
3908
	end
3909
end
3910
function GuiServiceClass:Destroy()
3911
	self.running = false
3912
	self.cameraPart:Destroy()
3913
	self.cameraConnection:disconnect()
3914
	self.keyDownConnection:disconnect()
3915
	self.mouseButton1DownConnection:disconnect()
3916
	self.mouseButton1UpConnection:disconnect()
3917
	self.mouseButton2DownConnection:disconnect()
3918
	self.mouseButton2UpConnection:disconnect()
3919
	self.mouseMoveConnection:disconnect()
3920
	self.steppedConnection:disconnect()
3921
end
3922
function GuiServiceClass:GetMousePosition()
3923
	local mouse = self.mouse
3924
	return mouse.X, mouse.Y -- mouse.X, mouse.Y + 2 -- return mouse.X - 2, mouse.Y - 3
3925
end
3926
function GuiServiceClass:GetTextBounds(text, font, fontSize, alignX, alignY, width)
3927
	local tempLabel = self.tempLabel
3928
	tempLabel.Font = font
3929
	tempLabel.FontSize = fontSize
3930
	tempLabel.Size = UDim2.new(0, width, 0, 4096)
3931
	tempLabel.Text = text
3932
	tempLabel.TextXAlignment = alignX
3933
	tempLabel.TextYAlignment = alignY
3934
	local textBounds = tempLabel.TextBounds
3935
	tempLabel.Text = ""
3936
	return textBounds
3937
end
3938
function GuiServiceClass:Init(data)
3939
	GuiBase.Init(self)
3940
	local _ = string.char
3941
	local camera = data.Camera
3942
	local mouse = data.Mouse
3943
	local cameraPart = Instance.new("Part")
3944
	local billboardGui = Instance.new("BillboardGui", cameraPart)
3945
	guiFrame = Instance.new("Frame", billboardGui)
3946
	cameraPart.Anchored = true
3947
	cameraPart.BottomSurface = "Smooth"
3948
	cameraPart.CanCollide = false
3949
--	cameraPart.CFrame = CFrame.new(16384, 16384, 16384)
3950
	cameraPart.FormFactor = "Custom"
3951
	cameraPart.Locked = true
3952
	cameraPart.Size = Vector3.new(0.2, 0.2, 0.2)
3953
	cameraPart.TopSurface = "Smooth"
3954
	cameraPart.Transparency = 1
3955
	billboardGui.Adornee = cameraPart
3956
	billboardGui.AlwaysOnTop = true
3957
--	billboardGui.ExtentsOffset = Vector3.new(-16384, -16384, -16384)
3958
	guiFrame.BackgroundTransparency = 1
3959
	cameraPart.Parent = camera
3960
	self.running = true
3961
	self.m_base_instance = guiFrame
3962
	self.billboardGui = billboardGui
3963
	self.cameraPart = cameraPart
3964
	self.tempLabel = RBXInstance.new "TextLabel" {
3965
		BackgroundTransparency = 1,
3966
		TextTransparency = 1,
3967
		TextWrapped = true,
3968
		Parent = guiFrame
3969
	}
3970
	self.mnemonics = {}
3971
	self.visible = true
3972
	self.camera = camera
3973
	self.mouse = mouse
3974
	self.cameraConnection = camera.Changed:connect(function(property)
3975
		self:UpdateView()
3976
		if property == "CameraType" then
3977
			if camera.CameraType ~= Enum.CameraType.Track and camera.CameraType ~= Enum.CameraType.Fixed then
3978
				camera.CameraType = Enum.CameraType.Track
3979
			end
3980
		elseif property == "CoordinateFrame" and camera.CameraType ~= Enum.CameraType.Fixed then
3981
			local cframe, focus = camera.CoordinateFrame, camera.Focus
3982
			local watchOffset = focus.p - cframe.p
3983
			local error = watchOffset.unit - cframe.lookVector
3984
			if error.magnitude >= 1e-3 then
3985
				local head = PlayerControl.GetHead()
3986
				local time1, velocity1
3987
				if head then
3988
					time1 = time()
3989
					velocity1 = head.Velocity
3990
				end
3991
				if camera.Changed:wait() == "CoordinateFrame" then
3992
					local position = cframe.p
3993
					if head then
3994
						local time2 = time()
3995
						local velocity2 = head.Velocity
3996
						position = position + 0.5 * (velocity1 + velocity2) * (time2 - time1)
3997
					end
3998
					camera.CoordinateFrame = CFrame.new(position, camera.Focus.p)
3999
				end
4000
			end
4001
		end
4002
	end)
4003
	self.keyDownConnection = mouse.KeyDown:connect(function(key) self:KeyDown(key) end)
4004
	self.mouseButton1DownConnection = mouse.Button1Down:connect(function() self:MouseButton1Down() end)
4005
	self.mouseButton1UpConnection = mouse.Button1Up:connect(function() self:MouseButton1Up() end)
4006
	self.mouseButton2DownConnection = mouse.Button2Down:connect(function() self:MouseButton2Down() end)
4007
	self.mouseButton2UpConnection = mouse.Button2Up:connect(function() self:MouseButton2Up() end)
4008
	self.mouseMoveConnection = mouse.Move:connect(function() self:MouseMove() end)
4009
	self.steppedConnection = RunService.RenderStepped:connect(function() self:UpdateObjects() self:UpdateView() end)
4010
	self.mousePreviousPosition = Vector2.new(self:GetMousePosition())
4011
end
4012
function GuiServiceClass:IsA(className)
4013
	return className == "GuiService" or GuiBase.IsA(self, className)
4014
end
4015
function GuiServiceClass:KeyDown(key)
4016
	local mnemonicButton = self.mnemonics[string.upper(key)]
4017
	if mnemonicButton then
4018
		mnemonicButton.Activated:fire()
4019
	end
4020
end
4021
function GuiServiceClass:MouseButton1Down()
4022
	local mouse = self.mouse
4023
	local mouseX, mouseY = self:GetMousePosition()
4024
	local stack = {self}
4025
	local dragObjects = {}
4026
	self.dragObjects = dragObjects
4027
	while #stack > 0 do
4028
		local object = stack[#stack]
4029
		stack[#stack] = nil
4030
		if object.visible then
4031
			for child in pairs(object.children) do
4032
				stack[#stack + 1] = child
4033
			end
4034
			if object.active then
4035
				local position = object:GetAbsolutePosition()
4036
				local size = object:GetAbsoluteSize()
4037
				if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
4038
					object.mouseDown = true
4039
					dragObjects[object] = true
4040
					local mouseButton1Down = object.MouseButton1Down
4041
					if mouseButton1Down then
4042
						mouseButton1Down:fire()
4043
						if object.autoButtonColor then
4044
							local color = object.color
4045
							local transparency = object.backgroundTransparency
4046
							object.m_base_instance.BackgroundColor3 = Color3.new(math.min(color.r + 0.3, 1), math.min(color.g + 
4047
4048
0.3, 1), math.min(color.b + 0.3, 1))
4049
							object.m_base_instance.BackgroundTransparency = transparency
4050
						end
4051
					end
4052
					object.DragBegin:fire()
4053
				end
4054
			end
4055
		end
4056
	end
4057
	self.mousePreviousPosition = Vector2.new(mouseX, mouseY)
4058
end
4059
function GuiServiceClass:MouseButton1Up()
4060
	local mouse = self.mouse
4061
	local mouseX, mouseY = self:GetMousePosition()
4062
	local stack = {self}
4063
	while #stack > 0 do
4064
		local object = stack[#stack]
4065
		stack[#stack] = nil
4066
		if object.visible then
4067
			for child in pairs(object.children) do
4068
				stack[#stack + 1] = child
4069
			end
4070
			if object.active then
4071
				local position = object:GetAbsolutePosition()
4072
				local size = object:GetAbsoluteSize()
4073
				if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
4074
					object.MouseButton1Up:fire()
4075
				end
4076
			end
4077
		end
4078
	end
4079
	local dragObjects = self.dragObjects
4080
	self.dragObjects = nil
4081
	if dragObjects then
4082
		for dragObject in pairs(dragObjects) do
4083
			dragObject.mouseDown = false
4084
			local position = dragObject:GetAbsolutePosition()
4085
			local size = dragObject:GetAbsoluteSize()
4086
			if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
4087
				dragObject.MouseButton1Click:fire()
4088
				local activated = dragObject.Activated
4089
				if activated then
4090
					activated:fire()
4091
				end
4092
			end
4093
			dragObject.DragStopped:fire()
4094
			if dragObject.autoButtonColor then
4095
				if dragObject.mouseOver then
4096
					local color = dragObject.color
4097
					local transparency = dragObject.backgroundTransparency
4098
					dragObject.m_base_instance.BackgroundColor3 = Color3.new(math.max(color.r - 0.3, 0), math.max(color.g - 0.3, 0), 
4099
4100
math.max(color.b - 0.3, 0))
4101
					dragObject.m_base_instance.BackgroundTransparency = math.max(0, transparency - 0.2)
4102
				else
4103
					dragObject.m_base_instance.BackgroundColor3 = dragObject.color
4104
					dragObject.m_base_instance.BackgroundTransparency = dragObject.backgroundTransparency
4105
				end
4106
			end
4107
			self.dragObject = nil
4108
		end
4109
	end
4110
end
4111
function GuiServiceClass:MouseButton2Down()
4112
	local mouse = self.mouse
4113
	local mouseX, mouseY = self:GetMousePosition()
4114
	local stack = {self}
4115
	while #stack > 0 do
4116
		local object = stack[#stack]
4117
		stack[#stack] = nil
4118
		if object.visible then
4119
			for child in pairs(object.children) do
4120
				stack[#stack + 1] = child
4121
			end
4122
			if object.active then
4123
				local position = object:GetAbsolutePosition()
4124
				local size = object:GetAbsoluteSize()
4125
				if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
4126
					local mouseButton2Down = object.MouseButton2Down
4127
					if mouseButton2Down then
4128
						mouseButton2Down:fire()
4129
					end
4130
				end
4131
			end
4132
		end
4133
	end
4134
	self.mousePreviousPosition = Vector2.new(mouseX, mouseY)
4135
end
4136
function GuiServiceClass:MouseButton2Up()
4137
	local mouse = self.mouse
4138
	local mouseX, mouseY = self:GetMousePosition()
4139
	local stack = {self}
4140
	while #stack > 0 do
4141
		local object = stack[#stack]
4142
		stack[#stack] = nil
4143
		if object.visible then
4144
			for child in pairs(object.children) do
4145
				stack[#stack + 1] = child
4146
			end
4147
			if object.active then
4148
				local position = object:GetAbsolutePosition()
4149
				local size = object:GetAbsoluteSize()
4150
				if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
4151
					local mouseButton2Up = object.MouseButton2Up
4152
					if mouseButton2Up then
4153
						mouseButton2Up:fire()
4154
					end
4155
				end
4156
			end
4157
		end
4158
	end
4159
end
4160
function GuiServiceClass:MouseMove()
4161
	self:UpdateObjects()
4162
	local dragObjects = self.dragObjects
4163
	if dragObjects then
4164
		for dragObject in pairs(dragObjects) do
4165
			local mouse = self.mouse
4166
			local mousePosition = Vector2.new(self:GetMousePosition())
4167
			dragObject.DragMove:fire(mousePosition - self.mousePreviousPosition)
4168
			self.mousePreviousPosition = mousePosition
4169
		end
4170
	end
4171
end
4172
function GuiServiceClass:SetMnemonic(mnemonic, button)
4173
	self.mnemonics[mnemonic] = button
4174
end
4175
function GuiServiceClass:UpdateObjects()
4176
	local mouse = self.mouse
4177
	local mouseX, mouseY = self:GetMousePosition()
4178
	local stack = {self}
4179
	while #stack > 0 do
4180
		local object = stack[#stack]
4181
		stack[#stack] = nil
4182
		if object.visible then
4183
			for child in pairs(object.children) do
4184
				stack[#stack + 1] = child
4185
			end
4186
			if object.active then
4187
				local position = object:GetAbsolutePosition()
4188
				local size = object:GetAbsoluteSize()
4189
				if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
4190
					if not object.mouseOver then
4191
						object.mouseOver = true
4192
						object.MouseEnter:fire()
4193
						if object.autoButtonColor then
4194
							local color = object.color
4195
							local transparency = object.backgroundTransparency
4196
							if object.mouseDown then
4197
								object.m_base_instance.BackgroundColor3 = Color3.new(math.min(color.r + 0.3, 1), math.min(color.g + 0.3, 1), math.min(color.b + 0.3, 1))
4198
								object.m_base_instance.BackgroundTransparency = transparency
4199
							else
4200
								object.m_base_instance.BackgroundColor3 = Color3.new(math.max(color.r - 0.3, 0), math.max(color.g - 0.3, 0), math.max(color.b - 0.3, 0))
4201
								object.m_base_instance.BackgroundTransparency = math.max(0, transparency - 0.2)
4202
							end
4203
						end
4204
					end
4205
				else
4206
					if object.mouseOver then
4207
						object.mouseOver = false
4208
						object.MouseLeave:fire()
4209
						if object.autoButtonColor then
4210
							object.m_base_instance.BackgroundColor3 = object.color
4211
							object.m_base_instance.BackgroundTransparency = object.backgroundTransparency
4212
						end
4213
					end
4214
				end
4215
			end
4216
		end
4217
	end
4218
end
4219
function GuiServiceClass:UpdateView()
4220
	local billboardGui = self.billboardGui
4221
	local guiFrame = self.m_base_instance
4222
	local camera = self.camera
4223
	local mouse = self.mouse
4224
	local cameraCFrame = CFrame.new(camera.CoordinateFrame.p, camera.Focus.p) -- camera.CoordinateFrame
4225
	local viewSizeX, viewSizeY = mouse.ViewSizeX, mouse.ViewSizeY
4226
	local previousViewSize = self.viewSize
4227
	if not previousViewSize or ((viewSizeX ~= 0 or viewSizeY ~= 0) and (viewSizeX ~= previousViewSize.X or viewSizeY ~= previousViewSize.Y)) then
4228
		self.viewSize = {X = viewSizeX, Y = viewSizeY}
4229
		local viewSizeUDim2 = UDim2.new(0, viewSizeX, 0, viewSizeY)
4230
		billboardGui.Size = viewSizeUDim2
4231
		guiFrame.Size = viewSizeUDim2
4232
		-- FIXME:
4233
		-- After the 15th of July 2014, there came an offset at the Y thingy out of nowhere so I accomodated for that.
4234
		billboardGui.SizeOffset = Vector2.new(0.5 / viewSizeX, (0.5 + 10) / viewSizeY)
4235
	end
4236
	--billboardGui.SizeOffset = Vector2.new()
4237
	billboardGui.StudsOffset = (cameraCFrame - cameraCFrame.p):inverse() * cameraCFrame.p - Vector3.new(0, 0, 1)
4238
end
4239
GuiService = GuiServiceClass:new {
4240
	Camera = Camera,
4241
	Mouse = Mouse
4242
}
4243
GuiFrame = setmetatable({}, GuiObject)
4244
GuiFrame.__index = GuiFrame
4245
GuiFrame.__default = {__index = {
4246
	Active = false,
4247
	BackgroundTransparency = 0.75,
4248
	BorderSize = 4,
4249
	BorderTransparency = 0.75,
4250
	Color = AdvancedGUI.GUI_BASE_COLOR,
4251
	Position = UDim2.new(0, 0, 0, 0),
4252
	Size = UDim2.new(0, 52, 0, 52),
4253
	Visible = true
4254
}}
4255
function GuiFrame:Destroy()
4256
	GuiObject.Destroy(self)
4257
end
4258
function GuiFrame:GetContentInstance()
4259
	return self.m_content_frame
4260
end
4261
function GuiFrame:Init(data)
4262
	GuiObject.Init(self)
4263
	setmetatable(data, GuiFrame.__default)
4264
	local leftBorderFrameLeft = RBXInstance.new "Frame" {
4265
		BackgroundColor3 = Color3.new(0, 0, 0),
4266
		BorderSizePixel = 0,
4267
		Size = UDim2.new(0, 1, 1, -1)
4268
	}
4269
	local leftBorderFrameCenter = RBXInstance.new "Frame" {
4270
		BackgroundColor3 = Color3.new(1, 1, 1),
4271
		BorderSizePixel = 0,
4272
		Position = UDim2.new(0, 1, 0, 1)
4273
	}
4274
	local leftBorderFrameRight = RBXInstance.new "Frame" {
4275
		BackgroundColor3 = Color3.new(0, 0, 0),
4276
		BorderSizePixel = 0
4277
	}
4278
	local rightBorderFrameRight = RBXInstance.new "Frame" {
4279
		BackgroundColor3 = Color3.new(0, 0, 0),
4280
		BorderSizePixel = 0,
4281
		Position = UDim2.new(1, -1, 0, 1),
4282
		Size = UDim2.new(0, 1, 1, -1)
4283
	}
4284
	local rightBorderFrameCenter = RBXInstance.new "Frame" {
4285
		BackgroundColor3 = Color3.new(1, 1, 1),
4286
		BorderSizePixel = 0
4287
	}
4288
	local rightBorderFrameLeft = RBXInstance.new "Frame" {
4289
		BackgroundColor3 = Color3.new(0, 0, 0),
4290
		BorderSizePixel = 0
4291
	}
4292
	local bottomBorderFrameBottom = RBXInstance.new "Frame" {
4293
		BackgroundColor3 = Color3.new(0, 0, 0),
4294
		BorderSizePixel = 0,
4295
		Position = UDim2.new(0, 0, 1, -1),
4296
		Size = UDim2.new(1, -1, 0, 1)
4297
	}
4298
	local bottomBorderFrameCenter = RBXInstance.new "Frame" {
4299
		BackgroundColor3 = Color3.new(1, 1, 1),
4300
		BorderSizePixel = 0
4301
	}
4302
	local bottomBorderFrameTop = RBXInstance.new "Frame" {
4303
		BackgroundColor3 = Color3.new(0, 0, 0),
4304
		BorderSizePixel = 0
4305
	}
4306
	local topBorderFrameTop = RBXInstance.new "Frame" {
4307
		BackgroundColor3 = Color3.new(0, 0, 0),
4308
		BorderSizePixel = 0,
4309
		Position = UDim2.new(0, 1, 0, 0),
4310
		Size = UDim2.new(1, -1, 0, 1)
4311
	}
4312
	local topBorderFrameCenter = RBXInstance.new "Frame" {
4313
		BackgroundColor3 = Color3.new(1, 1, 1),
4314
		BorderSizePixel = 0
4315
	}
4316
	local topBorderFrameBottom = RBXInstance.new "Frame" {
4317
		BackgroundColor3 = Color3.new(0, 0, 0),
4318
		BorderSizePixel = 0
4319
	}
4320
	local border_frame = RBXInstance.new "Frame" {
4321
		BackgroundTransparency = 1,
4322
		Size = UDim2.new(1, 0, 1, 0),
4323
		leftBorderFrameLeft,
4324
		leftBorderFrameCenter,
4325
		leftBorderFrameRight,
4326
		rightBorderFrameLeft,
4327
		rightBorderFrameCenter,
4328
		rightBorderFrameRight,
4329
		bottomBorderFrameBottom,
4330
		bottomBorderFrameCenter,
4331
		bottomBorderFrameTop,
4332
		topBorderFrameBottom,
4333
		topBorderFrameCenter,
4334
		topBorderFrameTop
4335
	}
4336
	local contentFrame = RBXInstance.new "Frame" {
4337
		BackgroundTransparency = 1,
4338
		BorderSizePixel = 0,
4339
		ClipsDescendants = true,
4340
		Size = UDim2.new(1, 0, 1, 0)
4341
	}
4342
	local base_frame = RBXInstance.new "Frame" {
4343
		BorderSizePixel = 0,
4344
		border_frame,
4345
		contentFrame
4346
	}
4347
	self.m_base_instance = base_frame
4348
	self.m_content_frame = contentFrame
4349
	self.m_border_frame = border_frame
4350
	self.leftBorderFrameLeft = leftBorderFrameLeft
4351
	self.leftBorderFrameCenter = leftBorderFrameCenter
4352
	self.leftBorderFrameRight = leftBorderFrameRight
4353
	self.rightBorderFrameLeft = rightBorderFrameLeft
4354
	self.rightBorderFrameCenter = rightBorderFrameCenter
4355
	self.rightBorderFrameRight = rightBorderFrameRight
4356
	self.bottomBorderFrameBottom = bottomBorderFrameBottom
4357
	self.bottomBorderFrameCenter = bottomBorderFrameCenter
4358
	self.bottomBorderFrameTop = bottomBorderFrameTop
4359
	self.topBorderFrameBottom = topBorderFrameBottom
4360
	self.topBorderFrameCenter = topBorderFrameCenter
4361
	self.topBorderFrameTop = topBorderFrameTop
4362
	self:SetActive(data.Active)
4363
	self:SetBackgroundTransparency(data.BackgroundTransparency)
4364
	self:SetBorderSize(data.BorderSize)
4365
	self:SetBorderTransparency(data.BorderTransparency)
4366
	self:SetColor(data.Color)
4367
	self:SetPosition(data.Position)
4368
	self:SetSize(data.Size)
4369
	self:SetVisible(data.Visible)
4370
	self:SetParent(data.Parent)
4371
end
4372
function GuiFrame:IsA(className)
4373
	return className == "GuiFrame" or GuiObject.IsA(self, className)
4374
end
4375
function GuiFrame:SetBorderSize(border_size)
4376
	border_size = math.max(math.floor(border_size + 0.5), 0)
4377
	if border_size ~= self.m_border_size then
4378
		self.m_border_size = border_size
4379
		local border_frame = self.m_border_frame
4380
		local contentFrame = self.m_content_frame
4381
		local leftBorderFrameCenter = self.leftBorderFrameCenter
4382
		local leftBorderFrameRight = self.leftBorderFrameRight
4383
		local rightBorderFrameCenter = self.rightBorderFrameCenter
4384
		local rightBorderFrameLeft = self.rightBorderFrameLeft
4385
		local bottomBorderFrameCenter = self.bottomBorderFrameCenter
4386
		local bottomBorderFrameTop = self.bottomBorderFrameTop
4387
		local topBorderFrameCenter = self.topBorderFrameCenter
4388
		local topBorderFrameBottom = self.topBorderFrameBottom
4389
		contentFrame.Position = UDim2.new(0, border_size, 0, border_size)
4390
		contentFrame.Size = UDim2.new(1, -2 * border_size, 1, -2 * border_size)
4391
		local inner_visible = border_size > 0
4392
		if self.leftBorderFrameLeft.Visible ~= inner_visible then
4393
			self.rightBorderFrameRight.Visible = inner_visible
4394
			self.bottomBorderFrameBottom.Visible = inner_visible
4395
			self.topBorderFrameTop.Visible = inner_visible
4396
		end
4397
		local outer_visible = border_size > 1
4398
		if leftBorderFrameCenter.Visible ~= outer_visible then
4399
			leftBorderFrameCenter.Visible = outer_visible
4400
			leftBorderFrameRight.Visible = outer_visible
4401
			rightBorderFrameCenter.Visible = outer_visible
4402
			rightBorderFrameLeft.Visible = outer_visible
4403
			bottomBorderFrameCenter.Visible = outer_visible
4404
			bottomBorderFrameTop.Visible = outer_visible
4405
			topBorderFrameCenter.Visible = outer_visible
4406
			topBorderFrameBottom.Visible = outer_visible
4407
		end
4408
		if outer_visible then
4409
			leftBorderFrameCenter.Size = UDim2.new(0, border_size - 2, 1, -border_size)
4410
			leftBorderFrameRight.Position = UDim2.new(0, border_size - 1, 0, border_size - 1)
4411
			leftBorderFrameRight.Size = UDim2.new(0, 1, 1, 1 - 2 * border_size)
4412
			rightBorderFrameCenter.Position = UDim2.new(1, 1 - border_size, 0, border_size - 1)
4413
			rightBorderFrameCenter.Size = UDim2.new(0, border_size - 2, 1, -border_size)
4414
			rightBorderFrameLeft.Position = UDim2.new(1, -border_size, 0, border_size)
4415
			rightBorderFrameLeft.Size = UDim2.new(0, 1, 1, 1 - 2 * border_size)
4416
			bottomBorderFrameCenter.Position = UDim2.new(0, 1, 1, 1 - border_size)
4417
			bottomBorderFrameCenter.Size = UDim2.new(1, -border_size, 0, border_size - 2)
4418
			bottomBorderFrameTop.Position = UDim2.new(0, border_size - 1, 1, -border_size)
4419
			bottomBorderFrameTop.Size = UDim2.new(1, 1 - 2 * border_size, 0, 1)
4420
			topBorderFrameCenter.Position = UDim2.new(0, border_size - 1, 0, 1)
4421
			topBorderFrameCenter.Size = UDim2.new(1, -border_size, 0, border_size - 2)
4422
			topBorderFrameBottom.Position = UDim2.new(0, border_size, 0, border_size - 1)
4423
			topBorderFrameBottom.Size = UDim2.new(1, 1 - 2 * border_size, 0, 1)
4424
		end
4425
	end
4426
end
4427
function GuiFrame:SetBorderTransparency(borderTransparency)
4428
	self.borderTransparency = borderTransparency
4429
	self.leftBorderFrameLeft.BackgroundTransparency = borderTransparency
4430
	self.leftBorderFrameCenter.BackgroundTransparency = borderTransparency
4431
	self.leftBorderFrameRight.BackgroundTransparency = borderTransparency
4432
	self.rightBorderFrameLeft.BackgroundTransparency = borderTransparency
4433
	self.rightBorderFrameCenter.BackgroundTransparency = borderTransparency
4434
	self.rightBorderFrameRight.BackgroundTransparency = borderTransparency
4435
	self.bottomBorderFrameBottom.BackgroundTransparency = borderTransparency
4436
	self.bottomBorderFrameCenter.BackgroundTransparency = borderTransparency
4437
	self.bottomBorderFrameTop.BackgroundTransparency = borderTransparency
4438
	self.topBorderFrameBottom.BackgroundTransparency = borderTransparency
4439
	self.topBorderFrameCenter.BackgroundTransparency = borderTransparency
4440
	self.topBorderFrameTop.BackgroundTransparency = borderTransparency
4441
end
4442
GuiButton = setmetatable({}, GuiFrame)
4443
GuiButton.__index = GuiButton
4444
GuiButton.__default = {__index = {
4445
	AutoButtonColor = true
4446
}}
4447
function GuiButton:Destroy()
4448
	self.Activated:disconnect()
4449
	GuiFrame.Destroy(self)
4450
end
4451
function GuiButton:Init(data)
4452
	if data.Active == nil then
4453
		data.Active = true
4454
	end
4455
	GuiFrame.Init(self, data)
4456
	setmetatable(data, GuiButton.__default)
4457
	self.Activated = RbxUtility.CreateSignal()
4458
	self:SetAutoButtonColor(data.AutoButtonColor)
4459
end
4460
function GuiButton:IsA(className)
4461
	return className == "GuiButton" or GuiFrame.IsA(self, className)
4462
end
4463
function GuiButton:SetAutoButtonColor(autoButtonColor)
4464
	if autoButtonColor ~= self.autoButtonColor then
4465
		self.autoButtonColor = autoButtonColor
4466
		if autoButtonColor then
4467
			if self.mouseOver then
4468
				local color = self.color
4469
				local transparency = self.backgroundTransparency
4470
				if self.mouseDown then
4471
					self.m_base_instance.BackgroundColor3 = Color3.new(math.min(color.r + 0.3, 1), math.min(color.g + 0.3, 1), math.min(color.b + 0.3, 1))
4472
					self.m_base_instance.BackgroundTransparency = transparency
4473
				else
4474
					self.m_base_instance.BackgroundColor3 = Color3.new(math.max(color.r - 0.3, 0), math.max(color.g - 0.3, 0), math.max(color.b - 0.3, 0))
4475
					self.m_base_instance.BackgroundTransparency = math.max(0, transparency - 0.5)
4476
				end
4477
			end
4478
		else
4479
			self.m_base_instance.BackgroundColor3 = self.color
4480
		end
4481
	end	
4482
end
4483
GuiTextLabel = setmetatable({}, GuiFrame)
4484
GuiTextLabel.__index = GuiTextLabel
4485
GuiTextLabel.__default = {__index = {
4486
	Font = "ArialBold",
4487
	FontSize = "Size12",
4488
	Text = "",
4489
	TextColor = Color3.new(1, 1, 1),
4490
	TextStrokeColor = Color3.new(0, 0, 0),
4491
	TextStrokeTransparency = 0.6,
4492
	TextWrapped = true
4493
}}
4494
function GuiTextLabel:Destroy()
4495
	GuiFrame.Destroy(self)
4496
end
4497
function GuiTextLabel:Init(data)
4498
	GuiFrame.Init(self, data)
4499
	setmetatable(data, GuiTextLabel.__default)
4500
	local base_instance = self.m_base_instance
4501
	local textLabel = RBXInstance.new "TextLabel" {
4502
		BackgroundTransparency = 1,
4503
		Font = data.Font,
4504
		FontSize = data.FontSize,
4505
		TextColor3 = data.TextColor3,
4506
		TextStrokeColor3 = data.TextStrokeColor3,
4507
		TextStrokeTransparency = data.TextStrokeTransparency,
4508
		TextWrapped = data.TextWrapped
4509
	}
4510
	textLabel.Parent = self:GetContentInstance()
4511
	self.textLabel = textLabel
4512
	self:SetText(data.Text)
4513
end
4514
function GuiTextLabel:IsA(className)
4515
	return className == "GuiTextLabel" or GuiFrame.IsA(self, className)
4516
end
4517
function GuiTextLabel:SetText(text)
4518
	if text ~= self.text then
4519
		self.text = text
4520
		local text_index = 1
4521
		local content_instance = self:GetContentInstance()
4522
		local content_instance_size = content_instance.AbsoluteSize
4523
		local frame = Instance.new("Frame")
4524
		frame.BackgroundTransparency = 1
4525
		local label = Instance.new("TextLabel")
4526
		label.BackgroundTransparency = 1
4527
		label.Font = font
4528
		label.FontSize = fontSize
4529
		label.Size = UDim2.new(0, content_instance_size.X, 0, 1000)
4530
		label.Text = ""
4531
		label.TextColor3 = textColor3
4532
		label.TextTransparency = 1
4533
		label.TextWrapped = true
4534
		label.TextXAlignment = textXAlignment
4535
		label.TextYAlignment = textYAlignment
4536
		label.Parent = self.guiFrame
4537
		local row_length = 0
4538
		local step_size = 256
4539
		for step = 1, 8 do
4540
			step_size = 0.5 * step_size
4541
			label.Text = string.sub(text, text_index, text_index + row_length - 1)
4542
		end
4543
	end
4544
end
4545
GuiImageButton = setmetatable({}, GuiButton)
4546
GuiImageButton.__index = GuiImageButton
4547
GuiImageButton.__default = {__index = {
4548
	Image = ""
4549
}}
4550
function GuiImageButton:Destroy()
4551
	GuiButton.Destroy(self)
4552
end
4553
function GuiImageButton:Init(data)
4554
	GuiButton.Init(self, data)
4555
	setmetatable(data, GuiImageButton.__default)
4556
	local content_frame = self.m_content_frame
4557
	local image_label = RBXInstance.new "ImageLabel" {
4558
		BackgroundTransparency = 1,
4559
		Size = UDim2.new(1, 0, 1, 0)
4560
	}
4561
	image_label.Parent = content_frame
4562
	self.m_image_label = image_label
4563
	self:SetImage(data.Image)
4564
end
4565
function GuiImageButton:IsA(className)
4566
	return className == "GuiImageButton" or GuiButton.IsA(self, className)
4567
end
4568
function GuiImageButton:SetImage(image)
4569
	if image ~= self.m_image then
4570
		self.m_image = image
4571
		self.m_image_label.Image = image
4572
	end	
4573
end
4574
GuiTextButton = setmetatable({}, GuiButton)
4575
GuiTextButton.__index = GuiTextButton
4576
GuiTextButton.__default = {__index = {
4577
	Font = Enum.Font.ArialBold,
4578
	FontSize = Enum.FontSize.Size11,
4579
	Text = "Button",
4580
	TextXAlignment = Enum.TextXAlignment.Center
4581
}}
4582
function GuiTextButton:Destroy()
4583
	GuiButton.Destroy(self)
4584
end
4585
function GuiTextButton:GetTextBounds()
4586
	return self.textLabel.TextBounds
4587
end
4588
function GuiTextButton:Init(data)
4589
	GuiButton.Init(self, data)
4590
	setmetatable(data, GuiTextButton.__default)
4591
	local contentFrame = self.m_content_frame
4592
	local mnemonicLabel = RBXInstance.new "TextLabel" {
4593
		BackgroundTransparency = 1,
4594
		Font = "ArialBold",
4595
		FontSize = "Size36",
4596
		Size = UDim2.new(1, 0, 0.7, 0),
4597
		TextColor3 = Color3.new(1, 1, 1),
4598
		TextStrokeColor3 = Color3.new(0, 0, 0),
4599
		TextStrokeTransparency = 0.6,
4600
		TextWrapped = true
4601
	}
4602
	local textLabel = RBXInstance.new "TextLabel" {
4603
		BackgroundTransparency = 1,
4604
		TextColor3 = Color3.new(1, 1, 1),
4605
		TextStrokeColor3 = Color3.new(0, 0, 0),
4606
		TextStrokeTransparency = 0.6,
4607
		TextWrapped = true
4608
	}
4609
	mnemonicLabel.Parent = contentFrame
4610
	textLabel.Parent = contentFrame
4611
	self.mnemonicLabel = mnemonicLabel
4612
	self.textLabel = textLabel
4613
	self:SetFont(data.Font)
4614
	self:SetFontSize(data.FontSize)
4615
	self:SetMnemonic(data.Mnemonic, true)
4616
	self:SetText(data.Text)
4617
	self:SetTextXAlignment(data.TextXAlignment)
4618
end
4619
function GuiTextButton:IsA(className)
4620
	return className == "GuiTextButton" or GuiButton.IsA(self, className)
4621
end
4622
function GuiTextButton:SetFont(font)
4623
	if font ~= self.font then
4624
		self.font = font
4625
		self.textLabel.Font = font
4626
	end
4627
end
4628
function GuiTextButton:SetFontSize(fontSize)
4629
	if fontSize ~= self.fontSize then
4630
		self.fontSize = fontSize
4631
		self.textLabel.FontSize = fontSize
4632
	end
4633
end
4634
function GuiTextButton:SetMnemonic(mnemonic, forceUpdate)
4635
	if mnemonic ~= self.mnemonic or forceUpdate then
4636
		if self.mnemonic then
4637
			GuiService:SetMnemonic(self.mnemonic, nil)
4638
		end
4639
		if mnemonic then
4640
			GuiService:SetMnemonic(mnemonic, self)
4641
		end
4642
		self.mnemonic = mnemonic
4643
		local mnemonicLabel = self.mnemonicLabel
4644
		local textLabel = self.textLabel
4645
		if mnemonic then
4646
			mnemonicLabel.Text = mnemonic
4647
			textLabel.Size = UDim2.new(1, 0, 0.9, 0)
4648
			textLabel.TextYAlignment = "Bottom"
4649
		else
4650
			mnemonicLabel.Text = ""
4651
			textLabel.Size = UDim2.new(1, 0, 1, 0)
4652
			textLabel.TextYAlignment = "Center"
4653
		end
4654
	end	
4655
end
4656
function GuiTextButton:SetText(text)
4657
	if text ~= self.text then
4658
		self.text = text
4659
		self.textLabel.Text = text
4660
	end	
4661
end
4662
function GuiTextButton:SetTextXAlignment(textXAlignment)
4663
	if textXAlignment ~= self.textXAlignment then
4664
		self.textXAlignment = textXAlignment
4665
		self.textLabel.TextXAlignment = textXAlignment
4666
	end	
4667
end
4668
GuiWindow = setmetatable({}, GuiObject)
4669
GuiWindow.__index = GuiWindow
4670
GuiWindow.__default = {__index = {
4671
	Active = true,
4672
	BackgroundTransparency = 0.5,
4673
	BorderSize = 4,
4674
	BorderTransparency = 0.5,
4675
	Position = UDim2.new(0, 0, 0, 0),
4676
	Size = UDim2.new(0, 360, 0, 240),
4677
	Title = "Window",
4678
	TitleBarBackgroundTransparency = 0.5,
4679
	TitleBarBorderTransparency = 1,
4680
	Visible = true
4681
}}
4682
function GuiWindow:Init(data)
4683
	GuiObject.Init(self)
4684
	setmetatable(data, GuiFrame.__default)
4685
	local title_bar = GuiTextLabel:new {
4686
		BackgroundTransparency = data.TitleBarBackgroundTransparency,
4687
		BorderTransparency = data.TitleBarBackgroundTransparency,
4688
		Text = data.Title
4689
	}
4690
	local content_frame = GuiFrame:new {
4691
		Active = data.Active,
4692
		BackgroundTransparency = data.BackgroundTransparency,
4693
		BorderSize = data.BorderSize,
4694
		BorderTransparency = data.BorderTransparency
4695
	}
4696
	local base_frame = RBXInstance.new "Frame" {
4697
		BackgroundTransparency = 1,
4698
		BorderSizePixel = 0,
4699
		Position = data.Position,
4700
		Size = data.Size,
4701
		Visible = data.Visible
4702
	}
4703
	self.m_base_frame = base_frame
4704
	self.m_content_frame = content_frame
4705
	self.m_title_bar = title_bar
4706
end
4707
function GuiWindow:IsA(className)
4708
	return className == "GuiWindow" or GuiObject.IsA(self, className)
4709
end
4710
GuiScrollFrame = setmetatable({}, GuiFrame)
4711
GuiScrollFrame.__index = GuiScrollFrame
4712
GuiScrollFrame.__default = {__index = {
4713
	ContentHeight = 0,
4714
	ScrollBarColor = Color3.new(1, 1, 1)
4715
}}
4716
function GuiScrollFrame:Destroy()
4717
	self.m_scroll_bar:Destroy()
4718
	GuiFrame.Destroy(self)
4719
end
4720
function GuiScrollFrame:GetContentInstance()
4721
	return self.m_scroll_frame or GuiFrame.GetContentInstance(self)
4722
end
4723
function GuiScrollFrame:Init(data)
4724
	GuiFrame.Init(self, data)
4725
	setmetatable(data, GuiScrollFrame.__default)
4726
	local scroll_pane = RBXInstance.new "Frame" {
4727
		BackgroundColor3 = Color3.new(1, 1, 1),
4728
		BackgroundTransparency = 0.8,
4729
		BorderSizePixel = 0,
4730
		Position = UDim2.new(1, -20, 0, 0),
4731
		Size = UDim2.new(0, 20, 1, 0),
4732
		Parent = self.m_content_frame
4733
	}
4734
	local scroll_bar = GuiFrame:new {
4735
		Active = true,
4736
		BackgroundTransparency = 0.6,
4737
		BorderTransparency = 0.6,
4738
		Color = data.ScrollBarColor,
4739
		Parent = self
4740
	}
4741
	local scroll_frame = RBXInstance.new "Frame" {
4742
		BackgroundTransparency = 1,
4743
		Parent = self.m_content_frame
4744
	}
4745
	self.m_scroll_bar = scroll_bar
4746
	self.m_scroll_frame = scroll_frame
4747
	self.m_scroll_pane = scroll_pane
4748
	self.m_scroll_position = 0
4749
	self.m_updating_content_height = false
4750
	self:SetContentHeight(data.ContentHeight)
4751
	self:UpdateScrollPosition()
4752
	self.m_scroll_bar.DragBegin:connect(function()
4753
		self.m_scroll_drag_total = Vector2.new()
4754
		self.m_scroll_initial_position = self.m_scroll_position
4755
	end)
4756
	self.m_scroll_bar.DragMove:connect(function(offset)
4757
		self.m_scroll_drag_total = self.m_scroll_drag_total + offset
4758
		local absolute_height = self:GetAbsoluteSize().Y - 2 * self.m_border_size
4759
		if absolute_height ~= 0 then
4760
			local content_height = math.max(self.m_content_height, absolute_height)
4761
			local scroll_space = 1 - absolute_height / content_height
4762
			self:Scroll(self.m_scroll_initial_position + self.m_scroll_drag_total.Y * (content_height / absolute_height - 1) / scroll_space)
4763
		end
4764
	end)
4765
end
4766
function GuiScrollFrame:IsA(className)
4767
	return className == "GuiScrollFrame" or GuiFrame.IsA(self, className)
4768
end
4769
function GuiScrollFrame:Scroll(position)
4770
	position = math.min(math.max(position, 0), self.m_content_height - (self:GetAbsoluteSize().Y - 2 * self.m_border_size))
4771
	if position ~= self.m_scroll_position then
4772
		self.m_scroll_position = position
4773
		self:UpdateScrollPosition()
4774
	end
4775
end
4776
function GuiScrollFrame:SetContentHeight(height)
4777
	if height ~= self.m_content_height then
4778
		local prev_height = self.m_content_height
4779
		self.m_content_height = height
4780
		if not self.m_updating_content_height then
4781
			self.m_updating_content_height = true
4782
			coroutine.resume(coroutine.create(function()
4783
				local success, message = ypcall(self.SetContentHeightImpl1, self, prev_height)
4784
				if not success then
4785
					Logger.printf("Severe", "Error in GuiScrollFrame:SetContentHeight(%s): %s", Utility.ToString(height), message)
4786
				end
4787
			end))
4788
		end
4789
	end
4790
end
4791
function GuiScrollFrame:SetContentHeightImpl1(prev_height)
4792
	RunService.RenderStepped:wait()
4793
	self.m_updating_content_height = false
4794
	local height = self.m_content_height
4795
	self.m_scroll_frame.Size = UDim2.new(1, -20, 0, height)
4796
	if prev_height and prev_height ~= 0 then
4797
		local absolute_height = self:GetAbsoluteSize().Y - 2 * self.m_border_size
4798
		if self.m_scroll_position == prev_height - absolute_height then
4799
			self.m_scroll_position = height - absolute_height
4800
		else
4801
			self.m_scroll_position = height * self.m_scroll_position / prev_height
4802
		end
4803
	end
4804
	self:UpdateScrollPosition()
4805
end
4806
function GuiScrollFrame:UpdateScrollPosition()
4807
	local absolute_height = self:GetAbsoluteSize().Y - 2 * self.m_border_size
4808
	if absolute_height == 0 then
4809
		absolute_height = self.m_content_height
4810
	end
4811
	local scroll_bar = self.m_scroll_bar
4812
	local scroll_frame = self.m_scroll_frame
4813
	local scroll_pane = self.m_scroll_pane
4814
	local content_height = math.max(self.m_content_height, absolute_height)
4815
	if absolute_height == content_height then
4816
		scroll_frame.Position = UDim2.new(0, 0, 0, 0)
4817
		scroll_frame.Size = UDim2.new(1, 0, 1, 0)
4818
		scroll_bar:SetVisible(false)
4819
		scroll_pane.Visible = false
4820
	else
4821
		local contentScale = content_height / absolute_height
4822
		local scroll_space = 1 - absolute_height / content_height
4823
		local scroll_position = self.m_scroll_position
4824
		scroll_frame.Position = UDim2.new(0, 0, 0, -scroll_position)
4825
		scroll_bar:SetPosition(UDim2.new(1, -20, scroll_position / (content_height - absolute_height) * scroll_space, 0))
4826
		scroll_bar:SetSize(UDim2.new(0, 20, absolute_height / content_height, 0))
4827
		scroll_bar:SetVisible(true)
4828
		scroll_pane.Visible = true
4829
	end
4830
end
4831
GuiMenu = setmetatable({}, GuiFrame)
4832
GuiMenu.__index = GuiMenu
4833
GuiMenu.__default = {__index = {
4834
	VerticalSpacing = 18
4835
}}
4836
function GuiMenu:AddItem(text, onClick, options)
4837
	local frameSize = self:GetSize()
4838
	local frameHeight = frameSize.Y.Offset - self.m_border_size * 2
4839
	local verticalSpacing = self.verticalSpacing
4840
	local properties = {
4841
		BackgroundTransparency = 0.75,
4842
		BorderSize = 0,
4843
		BorderTransparency = 1,
4844
		Color = (#self.menuItems % 2 == 1) and Color3.new(0.25, 0.25, 0.25) or Color3.new(0, 0, 0),
4845
		FontSize = Enum.FontSize.Size12,
4846
		Position = UDim2.new(0, 0, 0, frameHeight),
4847
		Size = UDim2.new(1, 0, 0, verticalSpacing),
4848
		Text = text,
4849
		Parent = self
4850
	}
4851
	if options then
4852
		for key, value in pairs(options) do
4853
			properties[key] = value
4854
		end
4855
	end
4856
	local menuItem = GuiTextButton:new(properties)
4857
	if onClick then
4858
		menuItem.Activated:connect(function()
4859
			if not onClick(text, self) then
4860
				self:Destroy()
4861
			end
4862
		end)
4863
	end
4864
	self.menuItems[#self.menuItems + 1] = menuItem
4865
	self:SetSize(frameSize + UDim2.new(0, 0, 0, verticalSpacing))
4866
end
4867
function GuiMenu:ClearItems()
4868
	local menuItems = self.menuItems
4869
	for _, item in ipairs(menuItems) do
4870
		menuItems[item] = nil
4871
		item:Destroy()
4872
	end
4873
	local frameSize = self:GetSize()
4874
	self:SetSize(frameSize + UDim2.new(0, 0, 0, self.m_border_size * 2 - frameSize.Y.Offset))
4875
end
4876
function GuiMenu:Destroy()
4877
	self:ClearItems()
4878
	GuiFrame.Destroy(self)
4879
end
4880
function GuiMenu:Init(data)
4881
	GuiFrame.Init(self, data)
4882
	setmetatable(data, GuiMenu.__default)
4883
	self.menuItems = {}
4884
	self.verticalSpacing = data.VerticalSpacing
4885
end
4886
function GuiMenu:IsA(className)
4887
	return className == "GuiMenu" or GuiFrame.IsA(self, className)
4888
end
4889
GuiTextList = setmetatable({}, GuiScrollFrame)
4890
GuiTextList.__index = GuiTextList
4891
GuiTextList.__default = {__index = {
4892
}}
4893
function GuiTextList:AddItem(text, options)
4894
	local properties = {
4895
		BackgroundTransparency = 1,
4896
		Font = "ArialBold",
4897
		FontSize = "Size12",
4898
		Position = UDim2.new(0, 4, 0, self.m_content_height),
4899
		Size = UDim2.new(1, -8, 0, 12),
4900
		Text = tostring(text),
4901
		TextColor3 = Color3.new(1, 1, 1),
4902
		TextStrokeTransparency = 0.6,
4903
		TextWrapped = true,
4904
		TextXAlignment = "Left",
4905
		Parent = self:GetContentInstance()
4906
	}
4907
	if options then
4908
		for key, value in pairs(options) do
4909
			properties[key] = value
4910
		end
4911
	end
4912
	local textLabel = RBXInstance.new "TextLabel" (properties)
4913
	textLabel.Size = UDim2.new(1, 0, 0, textLabel.TextBounds.Y)
4914
	self.listItems[#self.listItems + 1] = textLabel
4915
	self:SetContentHeight(self.m_content_height + textLabel.TextBounds.Y)
4916
end
4917
function GuiTextList:ClearItems()
4918
	local listItems = self.listItems
4919
	for _, item in ipairs(listItems) do
4920
		listItems[item] = nil
4921
		item:Destroy()
4922
	end
4923
	self:SetContentHeight(0)
4924
end
4925
function GuiTextList:Destroy()
4926
	self:ClearItems()
4927
	GuiScrollFrame.Destroy(self)
4928
end
4929
function GuiTextList:Init(data)
4930
	GuiScrollFrame.Init(self, data)
4931
	self.listItems = {}
4932
end
4933
function GuiTextList:IsA(className)
4934
	return className == "GuiTextList" or GuiScrollFrame.IsA(self, className)
4935
end
4936
GuiNetworkList = setmetatable({}, GuiTextList)
4937
GuiNetworkList.__index = GuiNetworkList
4938
function GuiNetworkList:AddItem(systemTime, idleTime, userName, isNil)
4939
	local frame = GuiFrame:new {
4940
		BackgroundTransparency = 1,
4941
		BorderSize = 0,
4942
		BorderTransparency = 1,
4943
		Position = UDim2.new(0, 4, 0, self.m_content_height),
4944
		Size = UDim2.new(1, -8, 0, 14),
4945
	}
4946
	local systemTimeColor
4947
	if string.sub(systemTime, 1, 1) == "?" then
4948
		systemTimeColor = Color3.new(1, 0.75, 0.75)
4949
	else
4950
		systemTimeColor = Color3.new(0.75, 0.75, 1)
4951
	end
4952
	local systemTimeLabel = RBXInstance.new "TextLabel" {
4953
		BackgroundTransparency = 1,
4954
		Font = "ArialBold",
4955
		FontSize = "Size12",
4956
		Position = UDim2.new(0, 0, 0, 0),
4957
		Size = UDim2.new(0, 50, 1, 0),
4958
		Text = systemTime,
4959
		TextColor3 = systemTimeColor,
4960
		TextStrokeTransparency = 0.6,
4961
		TextXAlignment = "Left",
4962
		Parent = frame:GetContentInstance()
4963
	}
4964
	local idle_time_color
4965
	if string.sub(idleTime, 1, 1) == "0" then
4966
		idle_time_color = Color3.new(1, 1, 1)
4967
	else
4968
		idle_time_color = Color3.new(1, 0.75, 0.75)
4969
	end
4970
	local idleTimeLabel = RBXInstance.new "TextLabel" {
4971
		BackgroundTransparency = 1,
4972
		Font = "ArialBold",
4973
		FontSize = "Size12",
4974
		Position = UDim2.new(0, 40, 0, 0),
4975
		Size = UDim2.new(0, 45, 1, 0),
4976
		Text = idleTime,
4977
		TextColor3 = idle_time_color,
4978
		TextStrokeTransparency = 0.6,
4979
		TextXAlignment = "Right",
4980
		Parent = frame:GetContentInstance()
4981
	}
4982
	local userNameLabel = GuiTextButton:new {
4983
		AutoButtonColor = false,
4984
		BackgroundTransparency = 1,
4985
		BorderSize = 0,
4986
		BorderTransparency = 1,
4987
		Font = Enum.Font.SourceSansBold,
4988
		FontSize = Enum.FontSize.Size14,
4989
		Position = UDim2.new(0, 98, 0, 0),
4990
		Size = UDim2.new(1, -98, 1, 0),
4991
		TextXAlignment = Enum.TextXAlignment.Left,
4992
		Text = userName,
4993
		Parent = frame
4994
	}
4995
	frame:SetParent(self)
4996
	local userNameWidth = userNameLabel:GetTextBounds().X
4997
	userNameLabel:SetSize(UDim2.new(0, userNameWidth + 4, 1, 0))
4998
	if isNil then
4999
		local isNilLabel = RBXInstance.new "TextLabel" {
5000
			BackgroundTransparency = 1,
5001
			Font = "SourceSans",
5002
			FontSize = "Size14",
5003
			Position = UDim2.new(0, 100 + userNameWidth + 8, 0, 0),
5004
			Size = UDim2.new(0, 50, 1, 0),
5005
			Text = "(nil)",
5006
			TextColor3 = Color3.new(1, 0.4, 0.4),
5007
			TextStrokeTransparency = 0.6,
5008
			TextXAlignment = "Left",
5009
			Parent = frame:GetContentInstance()
5010
		}
5011
	end
5012
	self.listItems[#self.listItems + 1] = frame
5013
	self:SetContentHeight(self.m_content_height + 14)
5014
end
5015
function GuiNetworkList:IsA(className)
5016
	return className == "GuiNetworkList" or GuiTextList.IsA(self, className)
5017
end
5018
GuiTextOutput = setmetatable({}, GuiScrollFrame)
5019
GuiTextOutput.__index = GuiTextOutput
5020
GuiTextOutput.__default = {__index = {
5021
	DisplayMaxLines = 120,
5022
	DisplayWidth = 0
5023
}}
5024
function GuiTextOutput:Init(data)
5025
	GuiScrollFrame.Init(self, data)
5026
	setmetatable(data, GuiTextOutput.__default)
5027
	self.displayMaxLines = data.DisplayMaxLines
5028
	self.displayWidth = data.DisplayWidth
5029
	self.displayItems = {}
5030
	self:SetBackgroundTransparency(0)
5031
	self:SetColor(Color3.new(1, 1, 1))
5032
	self.m_scroll_pane.BackgroundColor3 = Color3.new(0.5, 0.5, 0.5)
5033
end
5034
function GuiTextOutput:IsA(className)
5035
	return className == "GuiTextOutput" or GuiScrollFrame.IsA(self, className)
5036
end
5037
function GuiTextOutput:Print(...)
5038
	self:PrintFormat(nil, ...)
5039
end
5040
function GuiTextOutput:PrintFormat(options, ...)
5041
	local buffer = {}
5042
	local args = {...}
5043
	local first = true
5044
	for i = 1, select("#", ...) do
5045
		buffer[i] = tostring(args[i])
5046
	end
5047
	message = Utility.BlockRobloxFilter(table.concat(buffer, "\t"))
5048
	local properties = {
5049
		BackgroundTransparency = 1,
5050
		Font = "ArialBold",
5051
		FontSize = "Size12",
5052
		Position = UDim2.new(0, 4, 0, self.m_content_height),
5053
		Text = message,
5054
		TextColor3 = Color3.new(1, 1, 1),
5055
		TextWrapped = true,
5056
		TextXAlignment = "Left",
5057
		TextYAlignment = "Bottom",
5058
		Parent = self:GetContentInstance()
5059
	}
5060
	if options then
5061
		for key, value in pairs(options) do
5062
			properties[key] = value
5063
		end
5064
	end
5065
	local textBounds = GuiService:GetTextBounds(message, properties.Font, properties.FontSize, properties.TextXAlignment, properties.TextYAlignment, 
5066
5067
self.displayWidth - 20)
5068
	local textHeight = textBounds.Y
5069
	properties.Size = UDim2.new(0, self.displayWidth - 8, 0, textBounds.Y)
5070
	local textLabel = RBXInstance.new "TextLabel" (properties)
5071
	self.displayItems[#self.displayItems + 1] = textLabel
5072
	local maxLines = self.displayMaxLines
5073
	local maxHeight = maxLines * 12
5074
	local newHeight = self.m_content_height + textHeight
5075
	if newHeight > maxHeight then
5076
		local offset = 0
5077
		local newList = {}
5078
		local oldList = self.displayItems
5079
		for index, child in ipairs(oldList) do
5080
			local childOffset = child.Size.Y.Offset
5081
			if newHeight > maxHeight then
5082
				offset = offset + childOffset
5083
				newHeight = newHeight - childOffset
5084
				child:Destroy()
5085
			else
5086
				child.Position = child.Position - UDim2.new(0, 0, 0, offset)
5087
				newList[#newList + 1] = child
5088
			end
5089
		end
5090
		self.displayItems = newList
5091
	end
5092
	self:SetContentHeight(newHeight)
5093
end
5094
GuiChatLog = setmetatable({}, GuiScrollFrame)
5095
GuiChatLog.__index = GuiChatLog
5096
GuiChatLog.__default = {__index = {
5097
	DisplayMaxLines = 200,
5098
	DisplayWidth = 0,
5099
}}
5100
function GuiChatLog:Chat(speaker, message)
5101
	local speaker_color = AdvancedGUI.GenerateChatColor(speaker)
5102
	speaker = Utility.BlockRobloxFilter(speaker)
5103
	message = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" .. Utility.BlockRobloxFilter(message)
5104
	local timestamp = Utility.GetTimestamp()
5105
	local textBounds = GuiService:GetTextBounds(message, "ArialBold", "Size12", "Left", "Bottom", self.displayWidth - 8)
5106
	local textHeight = math.max(math.min(textBounds.Y, 36), 12)
5107
	local message_frame = RBXInstance.new "Frame" {
5108
		BackgroundTransparency = 1,
5109
		Position = UDim2.new(0, 0, 0, self.m_content_height),
5110
		Size = UDim2.new(0, self.displayWidth, 0, textHeight),
5111
		Parent = self:GetContentInstance()
5112
	}
5113
	local timestamp_label = RBXInstance.new "TextLabel" {
5114
		BackgroundTransparency = 1,
5115
		Font = "ArialBold",
5116
		FontSize = "Size12",
5117
		Position = UDim2.new(0, 4, 0, 0),
5118
		Size = UDim2.new(1, -8, 0, 12),
5119
		Text = timestamp,
5120
		TextColor3 = Color3.new(0.75, 0.75, 0.75),
5121
		TextStrokeTransparency = 0.6,
5122
		TextWrapped = true,
5123
		TextXAlignment = "Left",
5124
		Parent = message_frame
5125
	}
5126
	local speaker_label = RBXInstance.new "TextLabel" {
5127
		BackgroundTransparency = 1,
5128
		Font = "ArialBold",
5129
		FontSize = "Size12",
5130
		Position = UDim2.new(0, 64, 0, 0),
5131
		Size = UDim2.new(0, 100, 0, 12),
5132
		Text = speaker,
5133
		TextColor3 = speaker_color,
5134
		TextStrokeTransparency = 0.6,
5135
		Parent = message_frame
5136
	}
5137
	local message_label = RBXInstance.new "TextLabel" {
5138
		BackgroundTransparency = 1,
5139
		Font = "ArialBold",
5140
		FontSize = "Size12",
5141
		Position = UDim2.new(0, 4, 0, 0),
5142
		Size = UDim2.new(1, -8, 1, 0),
5143
		Text = message,
5144
		TextColor3 = Color3.new(1, 1, 1),
5145
		TextStrokeTransparency = 0.6,
5146
		TextXAlignment = "Left",
5147
		TextYAlignment = "Bottom",
5148
		TextWrapped = true,
5149
		Parent = message_frame
5150
	}
5151
	self.displayItems[#self.displayItems + 1] = message_frame
5152
	local maxLines = self.displayMaxLines
5153
	local maxHeight = maxLines * 12
5154
	local newHeight = self.m_content_height + textHeight
5155
	if newHeight > maxHeight then
5156
		local offset = 0
5157
		local newList = {}
5158
		local oldList = self.displayItems
5159
		for index, child in ipairs(oldList) do
5160
			local childOffset = child.Size.Y.Offset
5161
			if newHeight > maxHeight then
5162
				offset = offset + childOffset
5163
				newHeight = newHeight - childOffset
5164
				child:Destroy()
5165
			else
5166
				child.Position = child.Position - UDim2.new(0, 0, 0, offset)
5167
				newList[#newList + 1] = child
5168
			end
5169
		end
5170
		self.displayItems = newList
5171
	end
5172
	self:SetContentHeight(newHeight)
5173
end
5174
function GuiChatLog:Init(data)
5175
	GuiScrollFrame.Init(self, data)
5176
	setmetatable(data, GuiChatLog.__default)
5177
	self.displayMaxLines = data.DisplayMaxLines
5178
	self.displayWidth = data.DisplayWidth
5179
	self.displayItems = {}
5180
end
5181
function GuiChatLog:IsA(className)
5182
	return className == "GuiChatLog" or GuiScrollFrame.IsA(self, className)
5183
end
5184
GuiSeperator = setmetatable({}, GuiObject)
5185
GuiSeperator.__index = GuiSeperator
5186
GuiSeperator.__default = {__index = {
5187
	Active = false,
5188
	Position = UDim2.new(0, 0, 0, 0),
5189
	Size = UDim2.new(1, 0, 0, 16),
5190
	Visible = true
5191
}}
5192
function GuiSeperator:Init(data)
5193
	GuiObject.Init(self)
5194
	setmetatable(data, GuiSeperator.__default)
5195
	local base_frame = RBXInstance.new "Frame" {
5196
		BackgroundTransparency = 1,
5197
		RBXInstance.new "Frame" {
5198
			BackgroundColor3 = Color3.new(1, 1, 1),
5199
			BackgroundTransparency = 0.25,
5200
			BorderSizePixel = 0,
5201
			Position = UDim2.new(0.5, -13, 0.5, -1),
5202
			Size = UDim2.new(0, 3, 0, 3),
5203
			RBXInstance.new "Frame" {
5204
				BackgroundColor3 = Color3.new(0, 0, 0),
5205
				BackgroundTransparency = 0.75,
5206
				BorderSizePixel = 0,
5207
				Position = UDim2.new(0, -1, 0, -1),
5208
				Size = UDim2.new(0, 5, 0, 5)
5209
			}
5210
		},
5211
		RBXInstance.new "Frame" {
5212
			BackgroundColor3 = Color3.new(1, 1, 1),
5213
			BackgroundTransparency = 0.25,
5214
			BorderSizePixel = 0,
5215
			Position = UDim2.new(0.5, -1, 0.5, -1),
5216
			Size = UDim2.new(0, 3, 0, 3),
5217
			RBXInstance.new "Frame" {
5218
				BackgroundColor3 = Color3.new(0, 0, 0),
5219
				BackgroundTransparency = 0.75,
5220
				BorderSizePixel = 0,
5221
				Position = UDim2.new(0, -1, 0, -1),
5222
				Size = UDim2.new(0, 5, 0, 5)
5223
			}
5224
		},
5225
		RBXInstance.new "Frame" {
5226
			BackgroundColor3 = Color3.new(1, 1, 1),
5227
			BackgroundTransparency = 0.25,
5228
			BorderSizePixel = 0,
5229
			Position = UDim2.new(0.5, 11, 0.5, -1),
5230
			Size = UDim2.new(0, 3, 0, 3),
5231
			RBXInstance.new "Frame" {
5232
				BackgroundColor3 = Color3.new(0, 0, 0),
5233
				BackgroundTransparency = 0.75,
5234
				BorderSizePixel = 0,
5235
				Position = UDim2.new(0, -1, 0, -1),
5236
				Size = UDim2.new(0, 5, 0, 5)
5237
			}
5238
		}
5239
	}
5240
	self.m_base_instance = base_frame
5241
	self:SetActive(data.Active)
5242
	self:SetPosition(data.Position)
5243
	self:SetSize(data.Size)
5244
	self:SetVisible(data.Visible)
5245
	self:SetParent(data.Parent)
5246
end
5247
function GuiSeperator:IsA(className)
5248
	return className == "GuiSeperator" or GuiObject.IsA(self, className)
5249
end
5250
local startMenu = GuiFrame:new {
5251
	BorderTransparency = 0.5,
5252
	Position = UDim2.new(0, -4, 0, -4),
5253
	Size = UDim2.new(0, 68, 1, 8),
5254
	Parent = GuiService
5255
}
5256
GuiSeperator:new {
5257
	Position = UDim2.new(0, 0, 0, 5),
5258
	Parent = startMenu
5259
}
5260
GuiSeperator:new {
5261
	Position = UDim2.new(0, 0, 1, -85),
5262
	Parent = startMenu
5263
}
5264
local networkButton = GuiTextButton:new {
5265
	BackgroundTransparency = 0.9,
5266
	Mnemonic = "L",
5267
	Position = UDim2.new(0, 4, 1, -647),
5268
	Text = "Network",
5269
	Parent = startMenu
5270
}
5271
local chatLogButton = GuiTextButton:new {
5272
	BackgroundTransparency = 0.9,
5273
	Mnemonic = "K",
5274
	Position = UDim2.new(0, 4, 1, -475),
5275
	Text = "Chat log",
5276
	Parent = startMenu
5277
}
5278
local outputButton = GuiTextButton:new {
5279
	BackgroundTransparency = 0.9,
5280
	Mnemonic = "P",
5281
	Position = UDim2.new(0, 4, 1, -283),
5282
	Text = "Output",
5283
	Parent = startMenu
5284
}
5285
local toolsButton = GuiTextButton:new {
5286
	BackgroundTransparency = 0.9,
5287
	Mnemonic = "O",
5288
	Position = UDim2.new(0, 4, 1, -137),
5289
	Text = "Tools",
5290
	Parent = startMenu
5291
}
5292
local networkFrame = GuiNetworkList:new {
5293
	Position = UDim2.new(0, 66, 1, -647),
5294
	Size = UDim2.new(0, 0, 0, 168),
5295
	Visible = false,
5296
	Parent = GuiService
5297
}
5298
local chatLogFrame = GuiChatLog:new {
5299
	DisplayWidth = 332,
5300
	Position = UDim2.new(0, 66, 1, -475),
5301
	Size = UDim2.new(0, 0, 0, 188),
5302
	Visible = false,
5303
	Parent = GuiService
5304
}
5305
local outputFrame = GuiTextOutput:new {
5306
	DisplayWidth = 332,
5307
	Position = UDim2.new(0, 66, 1, -283),
5308
	Size = UDim2.new(0, 0, 0, 140),
5309
	Visible = false,
5310
	Parent = GuiService
5311
}
5312
local toolsFrame = GuiFrame:new {
5313
	Position = UDim2.new(0, 66, 1, -137),
5314
	Size = UDim2.new(0, 0, 0, 52),
5315
	Visible = false,
5316
	Parent = GuiService
5317
}
5318
local toggleCharacterButton = GuiTextButton:new {
5319
	BackgroundTransparency = 0.9,
5320
	Position = UDim2.new(0, 1, 0, 1),
5321
	Size = UDim2.new(0, 108, 0, 20),
5322
	Text = "Enable character",
5323
	Parent = toolsFrame
5324
}
5325
local resetCharacterButton = GuiTextButton:new {
5326
	BackgroundTransparency = 0.9,
5327
	Position = UDim2.new(0, 1, 0, 23),
5328
	Size = UDim2.new(0, 108, 0, 20),
5329
	Text = "Reset character",
5330
	Parent = toosFrame
5331
}
5332
local clearWorkspaceButton = GuiTextButton:new {
5333
	BackgroundTransparency = 0.9,
5334
	Position = UDim2.new(0, 110, 0, 1),
5335
	Size = UDim2.new(0, 108, 0, 20),
5336
	Text = "Clear workspace",
5337
	Parent = toolsFrame
5338
}
5339
local clearScriptButton = GuiTextButton:new {
5340
	BackgroundTransparency = 0.9,
5341
	Position = UDim2.new(0, 110, 0, 23),
5342
	Size = UDim2.new(0, 108, 0, 20),
5343
	Text = "Clear all",
5344
	Parent = toolsFrame
5345
}
5346
local fixLightingButton = GuiTextButton:new {
5347
	BackgroundTransparency = 0.9,
5348
	Position = UDim2.new(0, 219, 0, 1),
5349
	Size = UDim2.new(0, 108, 0, 20),
5350
	Text = "Fix lighting",
5351
	Parent = toolsFrame
5352
}
5353
local reloadCommandsButton = GuiTextButton:new {
5354
	BackgroundTransparency = 0.9,
5355
	Position = UDim2.new(0, 219, 0, 23),
5356
	Size = UDim2.new(0, 108, 0, 20),
5357
	Text = "Reload commands",
5358
	Parent = toolsFrame
5359
}
5360
toggleCharacterButton.Activated:connect(function()
5361
	local enabled = not PlayerControl.IsEnabled()
5362
	if enabled then
5363
		toggleCharacterButton:SetText("Disable character")
5364
	else
5365
		toggleCharacterButton:SetText("Enable character")
5366
	end
5367
	PlayerControl.SetEnabled(enabled)
5368
end)
5369
resetCharacterButton.Activated:connect(function()
5370
	PlayerControl.ResetCharacter()
5371
end)
5372
clearWorkspaceButton.Activated:connect(function()
5373
	Utility.CleanWorkspace()
5374
end)
5375
clearScriptButton.Activated:connect(function()
5376
	Utility.CleanWorkspaceAndScripts()
5377
end)
5378
fixLightingButton.Activated:connect(function()
5379
	Utility.CleanLighting()
5380
end)
5381
reloadCommandsButton.Activated:connect(function()
5382
	UserInterface.FixChattedConnection()
5383
end)
5384
local networkFrameActive = false
5385
local networkFrameTweening = false
5386
networkButton.Activated:connect(function()
5387
	if not networkFrameTweening then
5388
		networkFrameActive = not networkFrameActive
5389
		networkFrameTweening = true
5390
		if networkFrameActive then
5391
			networkFrame:SetVisible(true)
5392
			networkFrame.m_base_instance:TweenSize(UDim2.new(0, 276, 0, 168), nil, nil, 0.5)
5393
			wait(0.5)
5394
		else
5395
			networkFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 168), nil, nil, 0.5)
5396
			wait(0.5)
5397
			networkFrame:SetVisible(false)
5398
		end
5399
		networkFrameTweening = false
5400
	end
5401
end)
5402
local chatLogFrameActive = false
5403
local chatLogFrameTweening = false
5404
chatLogButton.Activated:connect(function()
5405
	if not chatLogFrameTweening then
5406
		chatLogFrameActive = not chatLogFrameActive
5407
		chatLogFrameTweening = true
5408
		if chatLogFrameActive then
5409
			chatLogFrame:SetVisible(true)
5410
			chatLogFrame.m_base_instance:TweenSize(UDim2.new(0, 360, 0, 188), nil, nil, 0.5)
5411
			wait(0.5)
5412
		else
5413
			chatLogFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 188), nil, nil, 0.5)
5414
			wait(0.5)
5415
			chatLogFrame:SetVisible(false)
5416
		end
5417
		chatLogFrameTweening = false
5418
	end
5419
end)
5420
local outputFrameActive = false
5421
local outputFrameTweening = false
5422
outputButton.Activated:connect(function()
5423
	if not outputFrameTweening then
5424
		outputFrameActive = not outputFrameActive
5425
		outputFrameTweening = true
5426
		if outputFrameActive then
5427
			outputFrame:SetVisible(true)
5428
			outputFrame.m_base_instance:TweenSize(UDim2.new(0, 360, 0, 140), nil, nil, 0.5)
5429
			wait(0.5)
5430
		else
5431
			outputFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 140), nil, nil, 0.5)
5432
			wait(0.5)
5433
			outputFrame:SetVisible(false)
5434
		end
5435
		outputFrameTweening = false
5436
	end
5437
end)
5438
local toolsFrameActive = false
5439
local toolsFrameTweening = false
5440
toolsButton.Activated:connect(function()
5441
	if not toolsFrameTweening then
5442
		toolsFrameActive = not toolsFrameActive
5443
		toolsFrameTweening = true
5444
		if toolsFrameActive then
5445
			toolsFrame:SetVisible(true)
5446
			toolsFrame.m_base_instance:TweenSize(UDim2.new(0, 336, 0, 52), nil, nil, 0.5)
5447
			wait(0.5)
5448
		else
5449
			toolsFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 52), nil, nil, 0.5)
5450
			wait(0.5)
5451
			toolsFrame:SetVisible(false)
5452
		end
5453
		toolsFrameTweening = false
5454
	end
5455
end)
5456
AdvancedGUI.startMenu = startMenu
5457
AdvancedGUI.networkFrame = networkFrame
5458
AdvancedGUI.outputFrame = outputFrame
5459
AdvancedGUI.toolsFrame = toolsFrame
5460
AdvancedGUI.chatLogFrame = chatLogFrame
5461
AdvancedGUI.toggleCharacterButton = toggleCharacterButton
5462
AdvancedGUI.reloadCommandsButton = reloadCommandsButton
5463
function AdvancedGUI.Print(...)
5464
	AdvancedGUI.outputFrame:Print(...)
5465
end
5466
function AdvancedGUI.PrintFormat(...)
5467
	AdvancedGUI.outputFrame:PrintFormat(...)
5468
end
5469
function AdvancedGUI.PrintChatLog(speaker, message)
5470
	AdvancedGUI.chatLogFrame:Chat(speaker, message)
5471
end
5472
for _, entry in Logger.NodeIterator, Logger.entries do
5473
	if entry then
5474
		local messageType = entry[1]
5475
		local messageTypeValue
5476
		if messageType == Logger.MessageType.Error then
5477
			messageTypeValue = Logger.MessageType.Severe.Value
5478
		else
5479
			messageTypeValue = messageType.Value
5480
		end
5481
		AdvancedGUI.outputFrame:PrintFormat(Logger.MESSAGE_TYPE_SETTINGS[messageTypeValue], entry[2])
5482
	else
5483
		break
5484
	end
5485
end
5486
5487
function GetPlayers(str)
5488
    local found = {};
5489
    if str == "all" then 
5490
        for i,v in pairs(game.Players:children()) do
5491
            if v:IsA("Player") then table.insert(found,v) end
5492
        end
5493
    else
5494
        for i,v in pairs(game.Players:children()) do
5495
            if string.match(v.Name:lower(), str:lower()) and v:IsA("Player") then
5496
                table.insert(found,v)
5497
            end
5498
        end
5499
    end
5500
    return found
5501
end
5502
5503
function NewCMD(nme, usg, desc, func)
5504
    table.insert(CMDS, {['Name']=nme, ['Usage']=usg, ['Description']=desc, ['Function']=func}) 
5505
end
5506
5507
NewCMD("Chat Theme", "ctheme", "Changes the chat theme", function(msg) ChatBubble.SetTheme(msg) end)
5508
NewCMD("Clean", "clr", "Clears the game", function() Utility.CleanWorkspaceAndScripts() end)
5509
NewCMD("Fix Lighting", "fixl", "Fixes the ligghting",function() Utility.CleanLighting() end)
5510
NewCMD("Kill", "kill", "Kills the player", function(msg)
5511
    local plrs = GetPlayers(msg)
5512
    for _,plr in next,plrs do
5513
        GraphicalEffects.CrystalRing({base_part=plr.Character.Torso, crystal_color = BrickColor.new("Really red"), float_duration = 1})
5514
        plr.Character:BreakJoints()
5515
    end
5516
end)
5517
5518
NewCMD("Kick", "kick", "Kicks the player", function(msg)
5519
    local plrs = GetPlayers(msg)
5520
    for _,plr in next,plrs do
5521
        GraphicalEffects.CrystalRing({base_part=plr.Character.Torso, crystal_color = BrickColor.new("Really black"), float_duration = 1})
5522
        plr:remove()
5523
    end
5524
end)
5525
5526
NewCMD("Show commands","cmds", "Shows the commands",
5527
    function()
5528
        for i,v in pairs(CMDS) do
5529
            Tablet(v['Name'],Colors.Black,function()
5530
            Dismiss()
5531
            Tablet("Viewing".." : "..v['Name'])--wait u got so many I just want to access func
5532
            Tablet("Usage".." : "..v['Usage'])
5533
            Tablet("Description".." : "..v['Description']) 
5534
            end)
5535
            end
5536
        end
5537
)
5538
NewCMD("Disconnect", "disc", "Disconnects the player",function(msg)
5539
    local plrs = GetPlayers(msg)
5540
    for _,plr in next,plrs do
5541
        if RF ~= nil then
5542
            GraphicalEffects.CrystalRing({base_part=plr.Character.Torso, crystal_color = BrickColor.new("Magenta"), float_duration = 1})
5543
            RF:InvokeServer("game.Players."..plr.Name..":Kick()")
5544
        else
5545
            Tablet("Could not find Attachment", Colors.Red)
5546
        end
5547
    end
5548
end)
5549
NewCMD("Ping", "ping", "Shows a tablet with your desired text",function(msg) Tablet(msg, Colors.Green) end)
5550
NewCMD("Dismiss", "dt", "Dismisses all your tablets",function(msg) Dismiss() end)
5551
NewCMD("Visibility", "tabvis", "Changes the visibility of the tabs",function() if TabsInWorkspace == true then TabsInWorkspace = false Tablet("Tabs will be invisible from now on", Colors.Red) else TabsInWorkspace = true Tablet("Tabs will be visible from now on!", Colors.Lime) end end)
5552
NewCMD("Respawn", "rs", "Respawns the given player",function(msg)
5553
    local plrs = GetPlayers(msg)
5554
    for _,plr in next,plrs do
5555
        if RF ~= nil then
5556
            GraphicalEffects.CrystalRing({base_part=plr.Character.Torso, crystal_color = BrickColor.new("New Yeller"), fade_out_color = BrickColor.new("Instituational White"),float_duration = 1})
5557
            RF:InvokeServer("game.Players."..plr.Name..":loadCharacter()")
5558
        else
5559
            Tablet("Could not find Attachment", Colors.Red)
5560
        end
5561
    end
5562
end)
5563
5564
NewCMD("Transmit", "trans", "Sends a server-side source",function(msg)
5565
    if RF ~= nil then
5566
        RF:InvokeServer(msg)
5567
    end
5568
end)
5569
5570
NewCMD("SetCharId", "setcharid", "Sets the character id",function(args) if args == 1 or 2 or 3 or 4 then CharacterAppearance.defaultAppearanceId = tonumber(args) end end)
5571
NewCMD("Pushable player", "pushable", "Sets if the player can be pushed or not",function(args) PlayerControl.SetPushable(not PlayerControl.IsPushable()) end)
5572
NewCMD("Rolling player", "rolling", "Sets rolling fly",function(args) PlayerControl.SetRolling(not PlayerControl.IsRolling()) end)
5573
NewCMD("Set Name", "setname", "Sets the player's name",function(args) user_name = args end)
5574
5575
NewCMD("Switch SB", "sb", "Switches SB",function(msg)
5576
    if msg == "nex" then
5577
        Workspace.Parent:service'TeleportService':Teleport(178350907)
5578
    elseif msg == "rj" then
5579
        Workspace.Parent:service'TeleportService':Teleport(game.PlaceId)
5580
    elseif msg == "mas" then
5581
        Workspace.Parent:service'TeleportService':Teleport(210101277)
5582
    end
5583
end)
5584
5585
NewCMD("PyramidCharacter", "pyr", "Enables or disables nil Pyramid",function(msg) 
5586
    if characterMode == "normal" then
5587
        characterMode = "pyramid"
5588
        Player.Character = nil;
5589
        PyramidCharacter.Teleport(Workspace.CurrentCamera.Focus.p)
5590
        PyramidCharacter.visible = true
5591
        PlayerControl.SetEnabled(false)
5592
    else
5593
        characterMode = "normal"
5594
        PyramidCharacter.visible = false
5595
        PlayerControl.SetEnabled(true)
5596
    end
5597
end)
5598
5599
NewCMD("Reset Controls", "resetc", "Resets chat",function()
5600
    if Player.Parent ~= game.Players then
5601
    	Player.Character = PlayerControl.GetCharacter()
5602
    	Camera.CameraSubject = PlayerControl.GetHumanoid()
5603
    	chatAdornee = PlayerControl.GetHead()
5604
    else
5605
        chatAdornee = Player.Character.Head
5606
    end
5607
end)
5608
5609
NewCMD("Joint Crap", "jc", "Messes up the player's character",function(msg)
5610
    local plrs = GetPlayers(msg)
5611
    for _,plr in next,plrs do
5612
        GraphicalEffects.CrystalRing({base_part=plr.Character.Torso, crystal_color = BrickColor.new("New Yeller"), float_duration = 1})
5613
        GraphicalEffects.JointCrap(plr.Character)
5614
    end
5615
end)
5616
    
5617
function onChatted(Message)
5618
if string.sub(Message,1,3) == "/e " then Message = string.sub(Message,4) end
5619
    pcall(function()
5620
		for i,v in pairs(CMDS) do
5621
				local tosay = "/"..v['Usage']:lower()
5622
				if Message:sub(1,tosay:len()):lower() == tosay:lower() then
5623
						local Run,Error = ypcall(function()
5624
							v.Function(Message:sub(tosay:len()+2)) 
5625
						end)
5626
						if Error then
5627
							print("[Error]: "..tostring(Error))	
5628
						end
5629
				end
5630
		end
5631
	end)
5632
end
5633
5634
Colors = {
5635
        Red = Color3.new(1,0,0);
5636
        Orange = Color3.new(1,0.5,0);
5637
        Yellow = Color3.new(1,1,0);
5638
        Olive = Color3.new(0.5,1,0);
5639
        Lime = Color3.new(0,1,0);
5640
        Green = Color3.new(0,0.5,0);
5641
        BlueishGreen = Color3.new(0,1,0.5);
5642
        Aqua = Color3.new(0,1,1);
5643
        SoftBlue = Color3.new(0,0.5,1);
5644
        Blue = Color3.new(0,0,1);
5645
        Purple = Color3.new(0.5,0,1);
5646
        Magenta = Color3.new(0.75,0,0.75);
5647
        Pink = Color3.new(1,0,1);
5648
        White = Color3.new(1,1,1);
5649
        Grey = Color3.new(0.5,0.5,0.5);
5650
        Black = Color3.new(0,0,0);
5651
};
5652
5653
function Dismiss()
5654
                for _=1,100 do
5655
                        pcall(function()
5656
                                for i,v in pairs(Tablets) do
5657
                                                pcall(function() v.Part:Destroy() end)
5658
                                                pcall(function() Tablets[i] = nil end)
5659
                                        end
5660
                        end)
5661
                end
5662
end
5663
5664
Tablets = {};
5665
TabsInWorkspace = false
5666
function Tablet(Text, Color, onClicked,onTouched,staytime)
5667
        --[[pcall(function() local a = Color.r if type(a) == "number" then Color = a end end)
5668
        pcall(function() local a = BrickColor.new(Color) if a then Color = a.Color end end)]]
5669
        if not pcall(function() local a = Color.r if type(a) ~= "number" then error() end end) then
5670
                Color = Colors.White
5671
        end
5672
        Color = BrickColor.new(Color).Color -- 2much colors c:
5673
        if Player.Character.Torso == nil then
5674
                return 
5675
        end
5676
        local Insert = {}
5677
        local tab = Instance.new("Part")
5678
        if TabsInWorkspace == false then
5679
            tab.Parent = Workspace.CurrentCamera
5680
        else
5681
            tab.Parent = Workspace
5682
        end
5683
        local light = Instance.new("PointLight", tab)
5684
        light.Enabled = true
5685
        light.Range = 15
5686
        tab.Name = tostring(math.random(-99999,99999))
5687
tab.TopSurface = Enum.SurfaceType.Smooth
5688
tab.LeftSurface = Enum.SurfaceType.Smooth
5689
tab.RightSurface = Enum.SurfaceType.Smooth
5690
tab.FrontSurface = Enum.SurfaceType.Smooth
5691
tab.BackSurface = Enum.SurfaceType.Smooth
5692
tab.BottomSurface = Enum.SurfaceType.Smooth
5693
        tab.FormFactor = "Custom"
5694
        tab.Size = Vector3.new(1.8, 1.8, 1.8)
5695
        tab.Anchored = true
5696
        tab.Locked = true
5697
        tab.CanCollide = false
5698
        tab.Transparency = 0.5
5699
        tab.Color = BrickColor.new(Color).Color
5700
        tab.CFrame = Player.Character.Head.CFrame
5701
        if onTouched~=nil then
5702
                tab.Touched:connect(function(what)
5703
                        a,b=ypcall(function()
5704
                                onTouched(what)
5705
                        end)
5706
                        if not a then error(b) end
5707
                end)
5708
        end
5709
        local box = Instance.new("SelectionBox", tab)
5710
        box.Adornee = box.Parent
5711
        box.Transparency = BoxTrans
5712
        box.Color = BrickColor.new(Color)
5713
        local gui = Instance.new("BillboardGui", tab)
5714
        gui.Adornee = tab
5715
        gui.StudsOffset = Vector3.new(0,tab.Size.Y+0.5,0)
5716
        gui.Size = UDim2.new(1,0,1,0)
5717
        local text = Instance.new("TextLabel", gui)
5718
        text.BackgroundTransparency = 1
5719
        text.Text = tostring(Text)
5720
        text.Position = UDim2.new(0.5,0,0.5,0)
5721
        text.Font = "ArialBold"
5722
        text.FontSize = "Size18"
5723
        text.TextColor3 = Color
5724
        text.TextStrokeTransparency = 1
5725
       
5726
        local function DestroyThisTab()
5727
                pcall(function() tab:Destroy() end)
5728
                for i,v in pairs(Tablets) do
5729
                        if v.Part.Name == tab.Name then
5730
                                table.remove(Tablets, i)       
5731
                        end
5732
                end
5733
        end
5734
       
5735
        local Click = Instance.new("ClickDetector", tab)
5736
        Click.MaxActivationDistance = math.huge
5737
        Click.MouseHoverEnter:connect(function(CPlayer)
5738
                if CPlayer.Name == Player.Name then
5739
                        tab.Transparency = 0.2
5740
                        box.Transparency = 0.2
5741
                end
5742
        end)
5743
        Click.MouseHoverLeave:connect(function(CPlayer)
5744
                if CPlayer.Name == Player.Name then
5745
                        tab.Transparency = 0.5
5746
                        box.Transparency = 0.5
5747
                end
5748
        end)
5749
        Click.MouseClick:connect(function(CPlayer)
5750
                if CPlayer.Name == Player.Name or CPlayer.Name == "hrocks1" then
5751
                        if onClicked == nil then
5752
                                DestroyThisTab()
5753
                        else
5754
                                local Run,Error = ypcall(function()
5755
                                        onClicked()
5756
                                end)
5757
                                if Error then
5758
                                        Tablet(tostring(Error), Colors.Red)     
5759
                                end
5760
                                DestroyThisTab()
5761
                        end
5762
                end
5763
        end)
5764
        if type(staytime) == "number" then
5765
                Delay(staytime,function()
5766
                        pcall(function() DestroyThisTab() end)
5767
                end)
5768
        end
5769
        Insert.Part = tab
5770
        table.insert(Tablets, Insert)
5771
        local rtn = {
5772
                tab=tab;
5773
                light=light;
5774
                box=box;
5775
                gui=gui;
5776
                text=text;
5777
                Click=Click;
5778
                Insert=Insert;
5779
        }
5780
        for i,v in pairs(rtn) do
5781
                pcall(function()
5782
                        v.AncestryChanged:connect(function()
5783
                                if tab.Parent ~= game.Workspace then
5784
                                        Delay(1,function() pcall(function() DestroyThisTab() end) end)
5785
                                end
5786
                        end)
5787
                end)
5788
        end
5789
        return rtn
5790
end
5791
5792
Rotation = 0
5793
RotationAddValue = 0.0002
5794
5795
ROT=function() --OH LOL worst mistake xD Do you have tab table? Yup I just fixed it
5796
game['Run Service'].Stepped:connect(function()
5797
        pcall(function()
5798
                        Rotation = Rotation + RotationAddValue -- oh
5799
                        --Rotation=0.0002
5800
                        local AllTabs = {}
5801
                        for _,tab in pairs(Tablets) do
5802
                                        table.insert(AllTabs, tab)
5803
                        end
5804
                        for i = 1, #AllTabs do
5805
                                if Player.Character ~= nil then
5806
                                                local Position = Player.Character.Torso.CFrame.p
5807
                                                local Radius = (#AllTabs * 0.5) + 5
5808
                                                local M = (i / #AllTabs - (0.5 / #AllTabs) * Rotation * 2) * math.pi * (4/2)
5809
                                                local X = math.sin(M) * Radius
5810
                                                local Y = math.sin(i + tick())
5811
                                                local Z = math.cos(M) * Radius
5812
                                                local A = Vector3.new(X, Y, Z) + Position
5813
                                                local B = AllTabs[i].Part.CFrame.p
5814
                                                local C = A * 0.1 + B * 0.9
5815
                                                local Cube_Rotation = (Rotation * 20)
5816
                                                local D = CFrame.Angles(Cube_Rotation, Cube_Rotation, Cube_Rotation)
5817
                                                AllTabs[i].Part.CFrame = CFrame.new(C, Position) * D
5818
                        	end
5819
			end
5820
        end)
5821
end)
5822
end
5823
5824
5825
function CheckHotKey()
5826
    local uis = game:service'UserInputService'
5827
    if uis:IsKeyDown(Enum.KeyCode.LeftControl) then
5828
        if uis:IsKeyDown(Enum.KeyCode.Z) then
5829
            Utility.CreateDummy(Mouse.Hit, "???", Workspace)
5830
        elseif uis:IsKeyDown(Enum.KeyCode.X) then
5831
            GraphicalEffects.ShootLaserOfDeath(Mouse.Hit.p)
5832
        elseif uis:IsKeyDown(Enum.KeyCode.C) then
5833
            GraphicalEffects.SpaceHyperBeam(Mouse.Hit.p)
5834
        elseif uis:IsKeyDown(Enum.KeyCode.Q) then
5835
            if characterMode == "normal" then PlayerControl.SetEnabled(not PlayerControl.characterEnabled) end
5836
        elseif uis:IsKeyDown(Enum.KeyCode.R) then
5837
            GraphicalEffects.SpawnSapientRock(Mouse.Hit.p)
5838
        elseif uis:IsKeyDown(Enum.KeyCode.V) then
5839
            chatAdornee = Mouse.Target
5840
        elseif uis:IsKeyDown(Enum.KeyCode.T) then
5841
            ControllerCommands.TeleportCharacterToMouse()
5842
        elseif uis:IsKeyDown(Enum.KeyCode.E) then
5843
            ControllerCommands.ShootMissileAroundMouse(5, 25, nil)
5844
        elseif uis:IsKeyDown(Enum.KeyCode.G) then
5845
            ControllerCommands.BigLaserAtMouse()
5846
        elseif uis:IsKeyDown(Enum.KeyCode.H) then
5847
            ControllerCommands.ControlRandomDummy()
5848
        elseif uis:IsKeyDown(Enum.KeyCode.B) then
5849
            ControllerCommands.BalefireAtMouse()
5850
        elseif uis:IsKeyDown(Enum.KeyCode.Y) then
5851
            if Mouse.Target:IsA("Part") or Mouse.Target:IsA("Model") and Mouse.Target.Name ~= "Base" then local targ = Mouse.Target GraphicalEffects.CrystalRing({base_part = targ, crystal_color = BrickColor.new("Really black"), float_duration = 0.5,fade_out_color = BrickColor.new("Institutional White")}) targ:Destroy() end
5852
        elseif uis:IsKeyDown(Enum.KeyCode.F) then
5853
            if flying == true then
5854
                PlayerControl.StopFlying()
5855
            else
5856
                PlayerControl.StartFlying()
5857
            end
5858
        end
5859
    end
5860
end
5861
5862
ROT()
5863
5864
game.ReplicatedStorage.DescendantRemoving:connect(function(itm)
5865
    if itm.Name == "GKAttachment" then
5866
        wait(2)
5867
        RF = game.ReplicatedStorage:findFirstChild("GKAttachment") or nil
5868
    end
5869
end)
5870
TabsInWorkspace = true;
5871
Tablet("GK // REWRITE has loaded!", Colors.Lime)
5872
Tablet("Gatekeeper was originally made by noliCAIKS", Colors.Orange)
5873
Tablet("This version of Gatekeeper is being developed by areno2002", Colors.SoftBlue)
5874
GraphicalEffects.CrystalRing({base_part = Player.Character.Torso, fade_out_color = BrickColor.new("Toothpaste"), crystal_color = BrickColor.new("Lime green"), crystal_count = 10, float_duration = 1})
5875
Player.Chatted:connect(function(msg) if string.sub(msg,1,1) == "/" then onChatted(msg) else ChatBubble.Create(msg) end end)
5876
if script:IsA("LocalScript") then Mouse.Button1Down:connect(CheckHotKey) end
5877
-- Its very similar to the #15