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