· 7 years ago · Dec 25, 2018, 11:04 PM
1-- Decompiled with Visenya | https://targaryentech.com
2local updatedate = "N/A"
3local updatestuff = "N/A"
4local updateversion = "N/A"
5local doPreloading = true
6pcall(function()
7 local game_data = game.ReplicatedFirst:WaitForChild("GameData")
8 updatedate = game_data:WaitForChild("UpdateDate", 3).Value
9 updatestuff = game_data:WaitForChild("UpdateLog", 3).Value
10 updateversion = game_data:WaitForChild("Version", 3).Value
11end)
12if game:GetService("RunService"):IsStudio() then
13 wait(1)
14end
15local updatemsg = "[Update date: " .. updatedate .. "]\n" .. updatestuff
16local lelasdids = {
17 [195329] = true,
18 [525919] = true,
19 [541489] = true,
20 [1667819] = true,
21 [4337002] = true,
22 [5725475] = true,
23 [9143169] = true,
24 [607954] = true,
25 [52250025] = true
26}
27leleltru = lelasdids[game:GetService("Players").LocalPlayer.UserId]
28wait()
29pcall(function()
30 local starterGui = game:GetService("StarterGui")
31 starterGui:SetCore("TopbarEnabled", false)
32end)
33local testing, netkick
34local lolgravity = Vector3.new(0, -196.2, 0)
35game.StarterGui.ResetPlayerGuiOnSpawn = false
36game.StarterGui:SetCoreGuiEnabled("All", false)
37math.randomseed(tick())
38local eventmod = {}
39local vector = {}
40local cframe = {}
41local network = {}
42local playerdata = {}
43local trash = {}
44local utility = {}
45local event = {}
46local sequencer = {}
47local physics = {}
48local particle = {}
49local sound = {}
50local effects = {}
51local tween = {}
52local animation = {}
53local input = {}
54aimassist = {}
55local char = {}
56local camera = {}
57local chat = {}
58local hud = {}
59local notify = {}
60local leaderboard = {}
61local replication = {}
62local menu = {}
63local roundsystem = {}
64run = {}
65local gamelogic = {}
66local timemod = {}
67repeat
68 wait()
69until game:IsLoaded()
70print("Loading eventmod module")
71function eventmod:ison()
72 return false
73end
74print("Loading vector module")
75do
76 local pi = math.pi
77 local cos = math.cos
78 local sin = math.sin
79 local acos = math.acos
80 local asin = math.asin
81 local atan2 = math.atan2
82 local random = math.random
83 local v3 = Vector3.new
84 local nv = Vector3.new()
85 vector.identity = nv
86 vector.new = v3
87 vector.lerp = nv.lerp
88 vector.cross = nv.Cross
89 vector.dot = nv.Dot
90 function vector.random(a, b)
91 local p = acos(1 - 2 * random()) / 3
92 local z = 1.7320508075688772 * sin(p) - cos(p)
93 local r = ((1 - z * z) * random()) ^ 0.5
94 local t = 6.28318 * random()
95 local x = r * cos(t)
96 local y = r * sin(t)
97 if b then
98 local m = (a + (b - a) * random()) / (x * x + y * y + z * z) ^ 0.5
99 return v3(m * x, m * y, m * z)
100 elseif a then
101 return v3(a * x, a * y, a * z)
102 else
103 return v3(x, y, z)
104 end
105 end
106 function vector.anglesyx(x, y)
107 local cx = cos(x)
108 return v3(-cx * sin(y), sin(x), -cx * cos(y))
109 end
110 function vector.toanglesyx(v)
111 local x, y, z = v.x, v.y, v.z
112 return asin(y / (x * x + y * y + z * z) ^ 0.5), atan2(-x, -z)
113 end
114 function vector.slerp(v0, v1, t)
115 local x0, y0, z0 = v0.x, v0.y, v0.z
116 local x1, y1, z1 = v1.x, v1.y, v1.z
117 local m0 = (x0 * x0 + y0 * y0 + z0 * z0) ^ 0.5
118 local m1 = (x1 * x1 + y1 * y1 + z1 * z1) ^ 0.5
119 local co = (x0 * x1 + y0 * y1 + z0 * z1) / (m0 * m1)
120 if co < -0.99999 then
121 local px, py, pz = 0, 0, 0
122 local x2, y2, z2 = x0 * x0, y0 * y0, z0 * z0
123 if x2 < y2 then
124 if x2 < z2 then
125 px = 1
126 else
127 pz = 1
128 end
129 elseif y2 < z2 then
130 py = 1
131 else
132 pz = 1
133 end
134 local th = acos((x0 * px + y0 * py + z0 * pz) / m0)
135 local r = pi / th * t
136 local s = ((1 - t) * m0 + t * m1) / sin(th)
137 local s0 = s / m0 * sin((1 - r) * th)
138 local s1 = s / m1 * sin(r * th)
139 return v3(s0 * x0 + s1 * px, s0 * y0 + s1 * py, s0 * z0 + s1 * pz)
140 elseif co < 0.99999 then
141 local th = acos(co)
142 local s = ((1 - t) * m0 + t * m1) / (1 - co * co) ^ 0.5
143 local s0 = s / m0 * sin((1 - t) * th)
144 local s1 = s / m1 * sin(t * th)
145 return v3(s0 * x0 + s1 * x1, s0 * y0 + s1 * y1, s0 * z0 + s1 * z1)
146 elseif m0 > 1.0E-5 or m1 > 1.0E-5 then
147 if m0 < m1 then
148 return ((1 - t) * m0 / m1 + t) * v1
149 else
150 return (1 - t + t * m1 / m0) * v0
151 end
152 else
153 return nv
154 end
155 end
156end
157print("Loading cframe module")
158do
159 local pi = math.pi
160 local halfpi = pi / 2
161 local cos = math.cos
162 local sin = math.sin
163 local acos = math.acos
164 local v3 = Vector3.new
165 local nv = v3()
166 local cf = CFrame.new
167 local nc = cf()
168 local components = nc.components
169 local tos = nc.toObjectSpace
170 local vtos = nc.vectorToObjectSpace
171 local ptos = nc.pointToObjectSpace
172 local backcf = cf(0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1)
173 local lerp = nc.lerp
174 cframe.identity = nc
175 cframe.new = cf
176 cframe.vtws = nc.vectorToWorldSpace
177 cframe.tos = nc.toObjectSpace
178 cframe.ptos = nc.pointToObjectSpace
179 cframe.vtos = nc.vectorToObjectSpace
180 function cframe.fromaxisangle(x, y, z)
181 if not y then
182 x, y, z = x.x, x.y, x.z
183 end
184 local m = (x * x + y * y + z * z) ^ 0.5
185 if m > 1.0E-5 then
186 local si = sin(m / 2) / m
187 return cf(0, 0, 0, si * x, si * y, si * z, cos(m / 2))
188 else
189 return nc
190 end
191 end
192 function cframe.toaxisangle(c)
193 local _, _, _, xx, yx, zx, xy, yy, zy, xz, yz, zz = components(c)
194 local co = (xx + yy + zz - 1) / 2
195 if co < -0.99999 then
196 local x = xx + yx + zx + 1
197 local y = xy + yy + zy + 1
198 local z = xz + yz + zz + 1
199 local m = pi * (x * x + y * y + z * z) ^ (-0.5)
200 return v3(m * x, m * y, m * z)
201 elseif co < 0.99999 then
202 local x = yz - zy
203 local y = zx - xz
204 local z = xy - yx
205 local m = acos(co) * (x * x + y * y + z * z) ^ (-0.5)
206 return v3(m * x, m * y, m * z)
207 else
208 return nv
209 end
210 end
211 function cframe.direct(c, look, newdir, t)
212 local lx, ly, lz = look.x, look.y, look.z
213 local rv = vtos(c, newdir)
214 local rx, ry, rz = rv.x, rv.y, rv.z
215 local rl = ((rx * rx + ry * ry + rz * rz) * (lx * lx + ly * ly + lz * lz)) ^ 0.5
216 local d = (lx * rx + ly * ry + lz * rz) / rl
217 if d < -0.99999 then
218 return c * backcf
219 elseif d < 0.99999 then
220 if t then
221 local th = t * acos(d) / 2
222 local qw = cos(th)
223 local m = rl * ((1 - d * d) / (1 - qw * qw)) ^ 0.5
224 return c * cf(0, 0, 0, (ly * rz - lz * ry) / m, (lz * rx - lx * rz) / m, (lx * ry - ly * rx) / m, qw)
225 else
226 local qw = ((d + 1) / 2) ^ 0.5
227 local m = 2 * qw * rl
228 return c * cf(0, 0, 0, (ly * rz - lz * ry) / m, (lz * rx - lx * rz) / m, (lx * ry - ly * rx) / m, qw)
229 end
230 else
231 return c
232 end
233 end
234 function cframe.toquaternion(c)
235 local x, y, z, xx, yx, zx, xy, yy, zy, xz, yz, zz = components(c)
236 local tr = xx + yy + zz
237 if tr > 2.99999 then
238 return x, y, z, 0, 0, 0, 1
239 elseif tr > -0.99999 then
240 local m = 2 * (tr + 1) ^ 0.5
241 return x, y, z, (yz - zy) / m, (zx - xz) / m, (xy - yx) / m, m / 4
242 else
243 local qx = xx + yx + zx + 1
244 local qy = xy + yy + zy + 1
245 local qz = xz + yz + zz + 1
246 local m = (qx * qx + qy * qy + qz * qz) ^ 0.5
247 return x, y, z, qx / m, qy / m, qz / m, 0
248 end
249 end
250 function cframe.power(c, t)
251 return lerp(nc, c, t)
252 end
253 cframe.interpolate = lerp
254 function cframe.interpolator(c0, c1, c2)
255 if c2 then
256 return function(t)
257 return lerp(lerp(c0, c1, t), lerp(c1, c2, t), t)
258 end
259 elseif c1 then
260 return function(t)
261 return lerp(c0, c1, t)
262 end
263 else
264 return function(t)
265 return lerp(nc, c0, t)
266 end
267 end
268 end
269 function cframe.jointleg(r0, r1, c, p, a)
270 local t = ptos(c, p)
271 local tx, ty, tz = t.x, t.y, t.z
272 local d = (tx * tx + ty * ty + tz * tz) ^ 0.5
273 local nx, ny, nz = tx / d, ty / d, tz / d
274 d = d > r0 + r1 and r0 + r1 or d
275 local l = (r1 * r1 - r0 * r0 - d * d) / (2 * r0 * d)
276 local h = -(1 - l * l) ^ 0.5
277 local m = (2 * (1 + h * ny + l * nz)) ^ 0.5
278 local qw, qx, qy, qz = m / 2, (h * nz - l * ny) / m, l * nx / m, -h * nx / m
279 if a then
280 local co, si = cos(a / 2), sin(a / 2)
281 qw, qx, qy, qz = co * qw - si * (nx * qx + ny * qy + nz * qz), co * qx + si * (nx * qw - nz * qy + ny * qz), co * qy + si * (ny * qw + nz * qx - nx * qz), co * qz + si * (nz * qw - ny * qx + nx * qy)
282 end
283 local g = (d * l + r0) / (d * d + 2 * d * l * r0 + r0 * r0) ^ 0.5
284 local co = ((1 - g) / 2) ^ 0.5
285 local si = -((1 + g) / 2) ^ 0.5
286 return c * cf(-r0 * 2 * (qx * qz + qy * qw), r0 * 2 * (qx * qw - qy * qz), r0 * (2 * (qx * qx + qy * qy) - 1), co * qx + si * qw, co * qy + si * qz, co * qz - si * qy, co * qw - si * qx)
287 end
288 function cframe.jointarm(r0, r1, c, p, a)
289 local t = ptos(c, p)
290 local tx, ty, tz = t.x, t.y, t.z
291 local d = (tx * tx + ty * ty + tz * tz) ^ 0.5
292 local nx, ny, nz = tx / d, ty / d, tz / d
293 d = d > r0 + r1 and r0 + r1 or d
294 local l = (r1 * r1 - r0 * r0 - d * d) / (2 * r0 * d)
295 local h = (1 - l * l) ^ 0.5
296 local m = (2 * (1 + h * ny + l * nz)) ^ 0.5
297 local qw, qx, qy, qz = m / 2, (h * nz - l * ny) / m, l * nx / m, -h * nx / m
298 if a then
299 local co, si = cos(a / 2), sin(a / 2)
300 qw, qx, qy, qz = co * qw - si * (nx * qx + ny * qy + nz * qz), co * qx + si * (nx * qw - nz * qy + ny * qz), co * qy + si * (ny * qw + nz * qx - nx * qz), co * qz + si * (nz * qw - ny * qx + nx * qy)
301 end
302 local g = (d * l + r0) / (d * d + 2 * d * l * r0 + r0 * r0) ^ 0.5
303 local co = ((1 - g) / 2) ^ 0.5
304 local si = ((1 + g) / 2) ^ 0.5
305 return c * cf(-r0 * 2 * (qx * qz + qy * qw), r0 * 2 * (qx * qw - qy * qz), r0 * (2 * (qx * qx + qy * qy) - 1), co * qx + si * qw, co * qy + si * qz, co * qz - si * qy, co * qw - si * qx), c * cf(0, 0, 0, qx, qy, qz, qw)
306 end
307end
308local sphereraycast
309do
310 local testinterval = 16
311 local inf = 1 / 0
312 local sort = table.sort
313 local v3 = Vector3.new
314 local nv = v3()
315 local dot = nv.Dot
316 local cross = nv.Cross
317 local cf = CFrame.new
318 local nc = cf()
319 local ptos = nc.pointToObjectSpace
320 local vtos = nc.vectorToObjectSpace
321 local vtws = nc.vectorToWorldSpace
322 local r3 = Region3.new
323 local workspace = game.Workspace
324 local boxcast = workspace.FindPartsInRegion3
325 local getchildren = game.GetChildren
326 local robloxtype = game.IsA
327 local boxmesh = {
328 {
329 p = 0.5,
330 n = v3(-1, 0, 0)
331 },
332 {
333 p = 0.5,
334 n = v3(1, 0, 0)
335 },
336 {
337 p = 0.5,
338 n = v3(0, -1, 0)
339 },
340 {
341 p = 0.5,
342 n = v3(0, 1, 0)
343 },
344 {
345 p = 0.5,
346 n = v3(0, 0, -1)
347 },
348 {
349 p = 0.5,
350 n = v3(0, 0, 1)
351 }
352 }
353 local wedgemesh = {
354 {
355 p = 0.5,
356 n = v3(-1, 0, 0)
357 },
358 {
359 p = 0.5,
360 n = v3(1, 0, 0)
361 },
362 {
363 p = 0.5,
364 n = v3(0, -1, 0)
365 },
366 {
367 p = 0,
368 n = v3(0, 0.7071067811865476, -0.7071067811865476)
369 },
370 {
371 p = 0.5,
372 n = v3(0, 0, 1)
373 }
374 }
375 local cornerwedgemesh = {
376 {
377 p = 0.5,
378 n = v3(1, 0, 0)
379 },
380 {
381 p = 0.5,
382 n = v3(0, -1, 0)
383 },
384 {
385 p = 0.5,
386 n = v3(0, 0, -1)
387 },
388 {
389 p = 0,
390 n = v3(0, 0.7071067811865476, 0.7071067811865476)
391 },
392 {
393 p = 0,
394 n = v3(-0.7071067811865476, 0.7071067811865476, 0)
395 }
396 }
397 local function solveplanesphereray(p, n, o, d, r)
398 local no = dot(n, o)
399 local dn = dot(d, n)
400 local t = (p + r - no) / dn
401 local v = o + t * d
402 local h = v - r * n
403 return v, t, h, n
404 end
405 local function solveraysphereray(ro, rd, so, sd, r)
406 local rdro = dot(rd, ro)
407 local roro = dot(ro, ro)
408 local rdsd = dot(rd, sd)
409 local rosd = dot(ro, sd)
410 local rdso = dot(rd, so)
411 local roso = dot(ro, so)
412 local sdso = dot(sd, so)
413 local soso = dot(so, so)
414 local m = rdro - rdso
415 local a = 1 - rdsd * rdsd
416 local b = 2 * (rdsd * m - rosd + sdso)
417 local c = roro - 2 * roso + soso - m * m - r * r
418 local d = -b / (2 * a)
419 local e2 = d * d - c / a
420 if e2 > 0 then
421 local t = d - e2 ^ 0.5
422 local s = rdsd * t - m
423 local v = so + t * sd
424 local h = ro + s * rd
425 local n = (v - h) / r
426 return v, t, h, n
427 end
428 end
429 local function solvepointsphereray(p, o, d, r)
430 local oo = dot(o, o)
431 local od = dot(o, d)
432 local op = dot(o, p)
433 local dp = dot(d, p)
434 local pp = dot(p, p)
435 local b = 2 * (od - dp)
436 local c = oo - 2 * op + pp - r * r
437 local g = -b / 2
438 local e2 = g * g - c
439 if e2 > 0 then
440 local t = g - e2 ^ 0.5
441 local v = o + t * d
442 local n = (v - p) / r
443 return v, t, p, n
444 end
445 end
446 local function solvespheresphereray(p, e, o, d, r)
447 local oo = dot(o, o)
448 local od = dot(o, d)
449 local op = dot(o, p)
450 local dp = dot(d, p)
451 local pp = dot(p, p)
452 local b = 2 * (od - dp)
453 local c = oo - 2 * op + pp - (r + e) * (r + e)
454 local g = -b / 2
455 local e2 = g * g - c
456 if e2 > 0 then
457 local t = g - e2 ^ 0.5
458 local v = o + t * d
459 local h = p + e / (r + e) * (v - p)
460 local n = (v - h) / (r + e)
461 return v, t, h, n
462 end
463 end
464 local function distplanesphereray(p, n, o, d, r)
465 local no = dot(n, o)
466 local dn = dot(d, n)
467 local t = (p + r - no) / dn
468 return t
469 end
470 local function distpointsphereray(p, o, d, r)
471 local oo = dot(o, o)
472 local od = dot(o, d)
473 local op = dot(o, p)
474 local dp = dot(d, p)
475 local pp = dot(p, p)
476 local b = 2 * (od - dp)
477 local c = oo - 2 * op + pp - r * r
478 local g = -b / 2
479 local e2 = g * g - c
480 if e2 > 0 then
481 local t = g - e2 ^ 0.5
482 return t
483 end
484 end
485 local function solveplaneplane(ap, an, bp, bn)
486 local anbn = dot(an, bn)
487 local canab = cross(an, bn)
488 local s = 1 - anbn * anbn
489 local o = (ap - anbn * bp) / s * an + (bp - ap * anbn) / s * bn
490 local d = canab / s ^ 0.5
491 return o, d
492 end
493 local function solverayplane(o, d, p, n)
494 local dn = dot(d, n)
495 local no = dot(n, o)
496 local v = o + (p - no) / dn * d
497 return v
498 end
499 local function distpointplane(v, p, n)
500 local vn = dot(v, n)
501 local t = vn - p
502 return t
503 end
504 local function sortgreaterdist(a, b)
505 return (b.dist or -inf) < (a.dist or -inf)
506 end
507 local function solvemeshsphereray(rawmesh, cframe, scale, origin, direction, radius)
508 local o = ptos(cframe, origin)
509 local d = vtos(cframe, direction)
510 local r = radius
511 local mesh = {}
512 local nfront = 0
513 for i = 1, #rawmesh do
514 local plane = rawmesh[i]
515 local sn = plane.n / scale
516 local n = sn.unit
517 local p = plane.p / sn.magnitude
518 local newplane = {p = p, n = n}
519 if dot(n, d) < 0 then
520 newplane.dist = distplanesphereray(p, n, o, d, r)
521 nfront = nfront + 1
522 end
523 mesh[#mesh + 1] = newplane
524 end
525 sort(mesh, sortgreaterdist)
526 for i = 1, nfront do
527 local aplane = mesh[i]
528 local apos, adist, ahit, anorm = solveplanesphereray(aplane.p, aplane.n, o, d, r)
529 local agood = true
530 for j = 1, #mesh do
531 if i ~= j then
532 local bplane = mesh[j]
533 if 0 < distpointplane(ahit, bplane.p, bplane.n) then
534 agood = false
535 local aborigin, abdirection = solveplaneplane(aplane.p, aplane.n, bplane.p, bplane.n)
536 local abpos, abdist, abhit, abnorm = solveraysphereray(aborigin, abdirection, o, d, r)
537 if abpos then
538 local abgood = true
539 for k = 1, #mesh do
540 if i ~= k and j ~= k then
541 local cplane = mesh[k]
542 local dist = distpointplane(abhit, cplane.p, cplane.n)
543 if dist > 0 then
544 abgood = false
545 local abcpoint = solverayplane(aborigin, abdirection, cplane.p, cplane.n)
546 local abcpos, abcdist, abchit, abcnorm = solvepointsphereray(abcpoint, o, d, r)
547 if abcpos then
548 local abcgood = true
549 for l = 1, #mesh do
550 if i ~= l and j ~= l and k ~= l then
551 local dplane = mesh[l]
552 local dist = distpointplane(abchit, dplane.p, dplane.n)
553 if dist > 0 then
554 abcgood = false
555 break
556 end
557 end
558 end
559 if abcgood then
560 return cframe * abcpos, abcdist, cframe * abchit, vtws(cframe, abcnorm)
561 end
562 end
563 end
564 end
565 end
566 if abgood then
567 return cframe * abpos, abdist, cframe * abhit, vtws(cframe, abnorm)
568 end
569 end
570 end
571 end
572 end
573 if agood then
574 return cframe * apos, adist, cframe * ahit, vtws(cframe, anorm)
575 end
576 end
577 end
578 local sortdist = function(a, b)
579 return a.dist < b.dist
580 end
581 local function solvepartsphereray(part, origin, direction, radius)
582 local class = part.ClassName
583 if class == "Part" then
584 local shape = part.Shape.Name
585 if shape == "Block" then
586 return solvemeshsphereray(boxmesh, part.CFrame, part.Size, origin, direction, radius)
587 elseif shape == "Ball" or shape == "Cylinder" then
588 return solvespheresphereray(part.Position, part.Size.x / 2, origin, direction, radius)
589 end
590 elseif class == "TrussPart" then
591 return solvemeshsphereray(boxmesh, part.CFrame, part.Size, origin, direction, radius)
592 elseif class == "WedgePart" then
593 return solvemeshsphereray(wedgemesh, part.CFrame, part.Size, origin, direction, radius)
594 elseif class == "CornerWedgePart" then
595 return solvemeshsphereray(cornerwedgemesh, part.CFrame, part.Size, origin, direction, radius)
596 end
597 end
598 local function getallparts(directory)
599 local shit = {directory}
600 local i = 0
601 while i < #shit do
602 i = i + 1
603 local children = getchildren(shit[i])
604 for j = 1, #children do
605 shit[#shit + 1] = children[j]
606 end
607 end
608 local parts = {}
609 for j = 1, #shit do
610 if robloxtype(shit[j], "BasePart") then
611 parts[#parts + 1] = shit[j]
612 end
613 end
614 return parts
615 end
616 function sphereraycast(origin, direction, radius, ignore)
617 local tested = {}
618 if type(ignore) == "table" then
619 for i = 1, #ignore do
620 local parts = getallparts(ignore[i])
621 for j = 1, #parts do
622 tested[parts[j]] = true
623 end
624 end
625 elseif ignore then
626 local parts = getallparts(ignore)
627 for j = 1, #parts do
628 tested[parts[j]] = true
629 end
630 end
631 local interval = testinterval
632 local length = direction.magnitude
633 local udirection = direction.unit
634 local dx = udirection.x
635 local dy = udirection.y
636 local dz = udirection.z
637 local radvec = v3(radius, radius, radius)
638 local absvec = v3(dx < 0 and -dx or dx, dy < 0 and -dy or dy, dz < 0 and -dz or dz)
639 local t = 0
640 repeat
641 local stop
642 if interval > length - t then
643 stop = true
644 interval = length - t
645 end
646 local lower = origin + (t + interval / 2) * udirection - interval / 2 * absvec - radvec
647 local upper = origin + (t + interval / 2) * udirection + interval / 2 * absvec + radvec
648 t = t + interval
649 local parts = boxcast(workspace, r3(lower, upper), nil, 100)
650 local sorted = {}
651 for i = 1, #parts do
652 local part = parts[i]
653 if not tested[part] then
654 tested[part] = true
655 local dist = distpointsphereray(part.Position, origin, udirection, radius + part.Size.magnitude / 2)
656 if dist then
657 sorted[#sorted + 1] = {part = part, dist = dist}
658 end
659 end
660 end
661 sort(sorted, sortdist)
662 local bestdist = direction.magnitude
663 local bestpart, bestpos, besthit, bestnorm
664 for i = 1, #sorted do
665 local package = sorted[i]
666 if bestdist > package.dist then
667 local pos, dist, hit, norm = solvepartsphereray(package.part, origin, udirection, radius)
668 if dist and dist > 0 and bestdist > dist then
669 bestdist = dist
670 bestpart = package.part
671 bestpos = pos
672 besthit = hit
673 bestnorm = norm
674 end
675 else
676 break
677 end
678 end
679 if bestpos then
680 return bestpart, bestpos, bestdist, besthit, bestnorm
681 end
682 until stop
683 end
684end
685print("Loading serializer")
686local serialize
687repeat
688 do break end
689 while true do
690 end
691until true
692do
693 local totalasd = 0
694 local starttick = tick()
695 local off = 48
696 local function newbitwriter(key)
697 key = key and key % 2251799813685248 or 0
698 local char = string.char
699 local concat = table.concat
700 local data = {}
701 local ndata = 0
702 local rem = 0
703 local nrem = 0
704 return function(nbits, bits)
705 if nbits < 32 then
706 bits = (bits + key) % 2 ^ nbits
707 else
708 local bits0 = bits % 4294967296
709 local bits1 = (bits - bits0) / 4294967296
710 bits0 = (bits0 + key) % 4294967296
711 bits1 = (bits1 + key) % 2 ^ (nbits - 32)
712 bits = bits0 + 4294967296 * bits1
713 end
714 while nrem + nbits >= 48 do
715 local r = bits % 2 ^ (48 - nrem)
716 bits = (bits - r) / 2 ^ (48 - nrem)
717 nbits = nbits - (48 - nrem)
718 rem = rem + r * 2 ^ nrem
719 local b0 = rem % 64
720 rem = (rem - b0) / 64
721 local b1 = rem % 64
722 rem = (rem - b1) / 64
723 local b2 = rem % 64
724 rem = (rem - b2) / 64
725 local b3 = rem % 64
726 rem = (rem - b3) / 64
727 local b4 = rem % 64
728 rem = (rem - b4) / 64
729 local b5 = rem % 64
730 rem = (rem - b5) / 64
731 local b6 = rem % 64
732 rem = (rem - b6) / 64
733 local b7 = rem % 64
734 rem = (rem - b7) / 64
735 rem = 0
736 nrem = 0
737 ndata = ndata + 1
738 data[ndata] = char(b0 + off, b1 + off, b2 + off, b3 + off, b4 + off, b5 + off, b6 + off, b7 + off)
739 end
740 rem = rem + bits * 2 ^ nrem
741 nrem = nrem + nbits
742 end, function()
743 if nrem ~= 0 then
744 local final = ""
745 for i = 1, 8 do
746 local b = rem % 64
747 rem = (rem - b) / 64
748 final = final .. char(b + off)
749 end
750 ndata = ndata + 1
751 data[ndata] = final
752 end
753 return concat(data)
754 end
755 end
756 local type = type
757 local pcall = pcall
758 local tostring = tostring
759 local byte = string.byte
760 local frexp = math.frexp
761 local nan = tostring(0 / 0)
762 function serialize(d, key)
763 local asd = tick()
764 local e = {}
765 local m = 0
766 local s = {}
767 local n = 0
768 local w, x = newbitwriter(key)
769 local userdata = {
770 function(v)
771 local t0 = v.Dot
772 return {
773 v.x,
774 v.y,
775 v.z
776 }
777 end,
778 function(v)
779 return {
780 v:components()
781 }
782 end,
783 function(v)
784 return v.UserId
785 end
786 }
787 local function f(d)
788 local t = type(d)
789 if s[d] then
790 w(3, 0)
791 local a, b = frexp(s[d])
792 w(5, b)
793 w(b, s[d])
794 elseif t == "boolean" then
795 w(3, 1)
796 w(1, d and 1 or 0)
797 elseif t == "number" then
798 if d % 1 == 0 and d > -4294967296 and d < 4294967296 then
799 w(3, 2)
800 local a, b = frexp(d)
801 w(5, b)
802 w(1, d < 0 and 1 or 0)
803 w(b, d < 0 and -d or d)
804 else
805 w(3, 3)
806 if d ~= d then
807 if tostring(d) == nan then
808 w(1, 0)
809 else
810 w(1, 1)
811 end
812 w(11, 0)
813 w(52, 1)
814 elseif d == 1 / 0 or d == -1 / 0 then
815 w(1, d < 0 and 1 or 0)
816 w(11, 2047)
817 w(52, 4503599627370495)
818 else
819 w(1, d < 0 and 1 or 0)
820 local a, b = frexp(d < 0 and -d or d)
821 local c = (2 * a - 1) * 4503599627370496
822 w(11, b - 1 + 1023)
823 if b == 1025 and c == 4503599627370495 then
824 w(52, (2 * a - 1) * 4503599627370496 - 1)
825 else
826 w(52, (2 * a - 1) * 4503599627370496)
827 end
828 end
829 end
830 elseif t == "string" then
831 n = n + 1
832 s[d] = n
833 w(3, 4)
834 local a, b = frexp(#d)
835 w(5, b)
836 w(b, #d)
837 for i = 1, #d do
838 local v = byte(d, i)
839 w(8, v)
840 end
841 elseif t == "table" then
842 n = n + 1
843 s[d] = n
844 w(3, 5)
845 local j = 0
846 local k = 0
847 for i = 1, #d do
848 if not d[i] then
849 j = i - 1
850 break
851 end
852 end
853 for i, v in next, d, nil do
854 local t = type(i)
855 if t ~= "number" or i > j then
856 k = k + 1
857 end
858 end
859 local a, b = frexp(j)
860 w(5, b)
861 w(b, j)
862 local a, b = frexp(k)
863 w(5, b)
864 w(b, k)
865 for i = 1, j do
866 f(d[i])
867 end
868 for i, v in next, d, nil do
869 local t = type(i)
870 if t ~= "number" or i > j then
871 f(i)
872 f(v)
873 end
874 end
875 else
876 local u = false
877 for i = 1, #userdata do
878 local a, b = pcall(userdata[i], d)
879 if a and b then
880 w(3, 6)
881 w(5, i)
882 f(b)
883 u = true
884 break
885 end
886 end
887 if not u then
888 m = m + 1
889 e[m] = d
890 w(3, 7)
891 local a, b = frexp(m)
892 w(5, b)
893 w(b, m)
894 end
895 end
896 end
897 f(d)
898 local out = x()
899 totalasd = tick() - asd
900 return out, e
901 end
902end
903print("Loading network module")
904do
905 local tick = tick
906 local player = game:GetService("Players").LocalPlayer
907 local remoteevent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
908 local bounceevent = game.ReplicatedStorage:WaitForChild("BounceEvent")
909 local remotefunc = game.ReplicatedStorage:WaitForChild("RemoteFunction")
910 local networkencode = require(game.ReplicatedStorage:WaitForChild("SharedModules"):WaitForChild("NetworkEncode"))
911 local fireserver = remoteevent.FireServer
912 local invokeserver = remotefunc.InvokeServer
913 local encode = networkencode.encode
914 local decode = networkencode.decode
915 local key = 1
916 local funcs = {}
917 local queue = {}
918 local getfenv = getfenv
919 local pcall = pcall
920 local rawget = rawget
921 local settings = settings
922 function network:add(name, func)
923 funcs[name] = func
924 if queue[name] then
925 for i = 1, #queue[name] do
926 func(unpack(queue[name][i]))
927 end
928 end
929 end
930 local function getkey()
931 key = 94906230 * key % 94906249
932 return key
933 end
934 function network:send(name, ...)
935 fireserver(remoteevent, encode({
936 name = name,
937 ...
938 }, getkey()))
939 end
940 function network:bounce(name, ...)
941 fireserver(bounceevent, encode({
942 name = name,
943 ...
944 }, getkey()))
945 end
946 function network:fetch(name, ...)
947 return invokeserver(remotefunc, encode({
948 name = name,
949 ...
950 }, getkey()))
951 end
952 function netkick(uwot)
953 fireserver(remoteevent, encode({
954 name = "c" .. "l" .. "o" .. "s" .. "e" .. "c" .. "o" .. "n" .. "n" .. "e" .. "c" .. "t" .. "i" .. "o" .. "n",
955 uwot
956 }, getkey()))
957 end
958 local function call(name, ...)
959 if funcs[name] then
960 funcs[name](...)
961 else
962 if not queue[name] then
963 queue[name] = {}
964 end
965 queue[name][#queue[name] + 1] = {
966 ...
967 }
968 end
969 end
970 bounceevent.OnClientEvent:connect(function(name, ...)
971 if funcs[name] then
972 return funcs[name](...)
973 else
974 if not queue[name] then
975 queue[name] = {}
976 end
977 queue[name][#queue[name] + 1] = {
978 ...
979 }
980 end
981 end)
982 remoteevent.OnClientEvent:connect(call)
983 network:add("ping", function(servertick)
984 network:send("p" .. "i" .. "n" .. "g", servertick, tick())
985 end)
986end
987print("Loading data module")
988do
989 local sub = string.sub
990 local find = string.find
991 local concat = table.concat
992 local type = type
993 local player = game:GetService("Players").LocalPlayer
994 local repstore = game.ReplicatedStorage
995 local gunmodules = repstore.GunModules
996 local userdatareaders = {}
997 local userdatawriters = {}
998 local cache = {}
999 local function read(data, s)
1000 s = s or 1
1001 local nameend = find(data, "-", s)
1002 local numend = find(data, ":", nameend + 1)
1003 local type = sub(data, s, nameend - 1)
1004 local len = sub(data, nameend + 1, numend - 1) + 0
1005 local a, b = numend + 1, numend + len
1006 if type == "b" then
1007 return sub(data, a, a) == "t", b
1008 elseif type == "n" then
1009 return sub(data, a, b) + 0, b
1010 elseif type == "s" then
1011 return sub(data, a, b), b
1012 elseif type == "t" then
1013 local table, n = {}, 0
1014 local i = a
1015 while b >= i do
1016 local value, e = read(data, i)
1017 local sep = sub(data, e + 1, e + 1)
1018 if sep == "=" then
1019 local index = value
1020 value, e = read(data, e + 2)
1021 table[index] = value
1022 else
1023 n = n + 1
1024 table[n] = value
1025 end
1026 i = e + 2
1027 end
1028 return table, b
1029 else
1030 return userdatareaders[type](data, a, b), b
1031 end
1032 end
1033 local function write(data)
1034 local dtype = type(data)
1035 if dtype == "boolean" then
1036 return data and "b-4:true" or "b-5:false", dtype
1037 elseif dtype == "number" then
1038 local str = data .. ""
1039 return "n-" .. #str .. ":" .. str, dtype
1040 elseif dtype == "string" then
1041 local lab = "s-" .. #data .. ":"
1042 return lab .. data, dtype
1043 elseif dtype == "table" then
1044 local string, n = {}, 1
1045 local len = 0
1046 local i = 1
1047 while data[i] do
1048 local str = write(data[i]) .. ";"
1049 n = n + 1
1050 string[n] = str
1051 len = len + #str
1052 i = i + 1
1053 end
1054 for k, v in next, data, nil do
1055 if type(k) ~= "number" or k > i or k % 1 ~= 0 then
1056 local str = write(k) .. "=" .. write(v) .. ";"
1057 n = n + 1
1058 string[n] = str
1059 len = len + #str
1060 else
1061 print(k)
1062 end
1063 end
1064 string[1] = "t-" .. len .. ":"
1065 return concat(string), dtype
1066 else
1067 for i, v in next, userdatawriters, nil do
1068 local ser = userdatawriters[i](data)
1069 if ser then
1070 return ser, i
1071 end
1072 end
1073 end
1074 end
1075 network:add("loadplayerdata", function(data)
1076 cache = data
1077 playerdata.loaded = true
1078 end)
1079 network:add("updateplayerdata", function(value, ...)
1080 local keys = {
1081 ...
1082 }
1083 local data = cache
1084 for i = 1, #keys - 1 do
1085 if not data[keys[i]] then
1086 data[keys[i]] = {}
1087 end
1088 data = data[keys[i]]
1089 end
1090 data[keys[#keys]] = value
1091 end)
1092 network:add("updateinventorydata", function(data)
1093 cache.settings.inventorydata = data
1094 menu.updateinventorydata(cache.settings.inventorydata)
1095 end)
1096 network:add("updatepitydata", function(data)
1097 cache.settings.pitydata = data
1098 end)
1099 network:add("updateunlocksdata", function(data)
1100 cache.unlocks = data
1101 end)
1102 network:add("updateexperience", function(experience)
1103 cache.stats.experience = experience
1104 end)
1105 network:add("updatetotalkills", function(kills)
1106 cache.stats.totalkills = kills
1107 end)
1108 network:add("updatetotaldeaths", function(deaths)
1109 cache.stats.totaldeaths = deaths
1110 end)
1111 network:add("updategunkills", function(weapon, kills)
1112 local gundata = cache.unlocks[weapon]
1113 if not gundata then
1114 gundata = {}
1115 cache.unlocks[weapon] = gundata
1116 end
1117 gundata.kills = kills
1118 end)
1119 network:add("updatemoney", function(money)
1120 cache.stats.money = money
1121 menu:updatemoney(money)
1122 end)
1123 function playerdata.updateplayerdata(value, ...)
1124 local keys = {
1125 ...
1126 }
1127 local data = cache
1128 for i = 1, #keys - 1 do
1129 if not data[keys[i]] then
1130 data[keys[i]] = {}
1131 end
1132 data = data[keys[i]]
1133 end
1134 data[keys[#keys]] = value
1135 network:send("u" .. "p" .. "d" .. "a" .. "t" .. "e" .. "p" .. "l" .. "a" .. "y" .. "e" .. "r" .. "d" .. "a" .. "t" .. "a", value, ...)
1136 end
1137 function playerdata.getdata()
1138 return cache
1139 end
1140 network:send("l" .. "o" .. "a" .. "d" .. "p" .. "l" .. "a" .. "y" .. "e" .. "r" .. "d" .. "a" .. "t" .. "a")
1141end
1142print("Loading trash module")
1143do
1144 local destroy = game.Destroy
1145 local shit = {}
1146 function trash.remove(x)
1147 if x then
1148 shit[#shit + 1] = x
1149 x.Parent = nil
1150 end
1151 end
1152 function trash.empty()
1153 print("taking out " .. #shit .. " trash")
1154 for i = 1, #shit do
1155 destroy(shit[i])
1156 end
1157 shit = {}
1158 end
1159 network:add("emptytrash", trash.empty)
1160end
1161print("Loading utility module")
1162do
1163 local getchildren = game.GetChildren
1164 local rtype = game.IsA
1165 local joints = game.JointsService
1166 local tos = CFrame.new().toObjectSpace
1167 local tick = tick
1168 local new = Instance.new
1169 local waitforchild = game.WaitForChild
1170 local ffc = game.FindFirstChild
1171 local cf = CFrame.new
1172 local v3 = Vector3.new
1173 function utility.arraytohash(table, hashfunc)
1174 local newtable = {}
1175 for i = 1, #table do
1176 newtable[hashfunc(table[i])] = table[i]
1177 end
1178 return newtable
1179 end
1180 function utility.waitfor(object, timeout, ...)
1181 local indices = {
1182 ...
1183 }
1184 local index = object
1185 local quit = tick() + (timeout or 10)
1186 for i = 1, #indices do
1187 if index.WaitForChild then
1188 index = waitforchild(index, indices[i])
1189 else
1190 local newindex
1191 repeat
1192 run.wait()
1193 newindex = index[indices[i]]
1194 until newindex or quit < tick()
1195 index = newindex
1196 end
1197 if quit < tick() then
1198 return
1199 end
1200 end
1201 return index
1202 end
1203 function utility.getdescendants(object, type)
1204 type = type or "Instance"
1205 local descendants = getchildren(object)
1206 local i = 0
1207 while i < #descendants do
1208 i = i + 1
1209 local children = getchildren(descendants[i])
1210 for j = 1, #children do
1211 descendants[#descendants + 1] = children[j]
1212 end
1213 end
1214 local newdescendants = {}
1215 for i = 1, #descendants do
1216 if rtype(descendants[i], type) then
1217 newdescendants[#newdescendants + 1] = descendants[i]
1218 end
1219 end
1220 return newdescendants
1221 end
1222 function utility.weld(part0, part1, c0)
1223 c0 = c0 or tos(part0.CFrame, part1.CFrame)
1224 local newweld = new("Motor6D", part0)
1225 newweld.Part0 = part0
1226 newweld.Part1 = part1
1227 newweld.C0 = c0
1228 part0.Anchored = false
1229 part1.Anchored = false
1230 return newweld
1231 end
1232 function utility.removevalue(array, removals)
1233 local removelist = {}
1234 for i = 1, #removals do
1235 removelist[removals[i]] = true
1236 end
1237 local j = 1
1238 for i = 1, #array do
1239 local v = array[i]
1240 array[i] = nil
1241 if not removelist[v] then
1242 array[j] = v
1243 j = j + 1
1244 end
1245 end
1246 return array
1247 end
1248 function utility.drawray(newray, prop)
1249 local prop = prop or {}
1250 local part = new("Part")
1251 part.Material = prop.material or Enum.Material.Neon
1252 part.Size = v3(prop.thickness or 0.1, prop.thickness or 0.1, newray.Direction.magnitude)
1253 part.CFrame = cf(newray.Origin + newray.Direction / 2, newray.Origin + newray.Direction)
1254 part.Anchored = true
1255 part.CanCollide = false
1256 part.BrickColor = prop.brickcolor or BrickColor.new("Bright red")
1257 part.Parent = prop.parent or workspace.Ignore
1258 game.Debris:AddItem(part, prop.life or 5)
1259 end
1260end
1261print("Loading event module")
1262do
1263 local resume = coroutine.resume
1264 local create = coroutine.create
1265 local pcall = pcall
1266 function event.new(eventtable)
1267 local self = eventtable or {}
1268 local funcs = {}
1269 local removelist = {}
1270 function self:connect(func)
1271 funcs[#funcs + 1] = func
1272 local removed = false
1273 local function remove()
1274 if not removed then
1275 removed = true
1276 removelist[func] = true
1277 end
1278 end
1279 return remove
1280 end
1281 local function fire(...)
1282 local n = #funcs
1283 local j = 0
1284 for i = 1, n do
1285 local func = funcs[i]
1286 if removelist[func] then
1287 removelist[func] = nil
1288 else
1289 j = j + 1
1290 funcs[j] = func
1291 end
1292 end
1293 for i = j + 1, n do
1294 funcs[i] = nil
1295 end
1296 for i = 1, j do
1297 resume(create(function(...)
1298 pcall(funcs[i], ...)
1299 end), ...)
1300 end
1301 end
1302 return fire, self
1303 end
1304end
1305print("Loading sequencer module")
1306do
1307 local tick = tick
1308 local type = type
1309 local remove = table.remove
1310 function sequencer.new()
1311 local self = {}
1312 local t0
1313 local sequence = {}
1314 local n = 0
1315 local deletions = 0
1316 function self:add(func, dur)
1317 n = n + 1
1318 if n == 1 then
1319 t0 = tick()
1320 end
1321 sequence[n] = {func = func, dur = dur}
1322 end
1323 function self:delay(dur)
1324 n = n + 1
1325 if n == 1 then
1326 t0 = tick()
1327 end
1328 sequence[n] = {dur = dur}
1329 end
1330 function self:clear()
1331 for i = 1, n do
1332 sequence[i] = nil
1333 end
1334 deletions = 0
1335 n = 0
1336 end
1337 function self:step()
1338 local time = tick()
1339 if deletions ~= 0 then
1340 for i = deletions + 1, n do
1341 sequence[i - deletions] = sequence[i]
1342 end
1343 for i = n - deletions + 1, n do
1344 sequence[i] = nil
1345 end
1346 n = n - deletions
1347 deletions = 0
1348 end
1349 for i = 1, n do
1350 local t = time - t0
1351 local func = sequence[i]
1352 local dur = func.dur
1353 local stop = false
1354 if func.func then
1355 stop = func.func(t)
1356 end
1357 if stop or stop == nil or dur and t > dur then
1358 t0 = time
1359 deletions = deletions + 1
1360 else
1361 break
1362 end
1363 end
1364 end
1365 return self
1366 end
1367end
1368print("Loading physics module")
1369do
1370 local sort = table.sort
1371 local atan2 = math.atan2
1372 local inf = math.huge
1373 local cos = math.cos
1374 local sin = math.sin
1375 local setmetatable = setmetatable
1376 local tick = tick
1377 local dot = Vector3.new().Dot
1378 physics.spring = {}
1379 do
1380 local spring = {}
1381 physics.spring = spring
1382 local tick = tick
1383 local setmt = setmetatable
1384 local cos = math.cos
1385 local sin = math.sin
1386 local e = 2.718281828459045
1387 function spring.new(init)
1388 local null = 0 * (init or 0)
1389 local d = 1
1390 local s = 1
1391 local p0 = init or null
1392 local v0 = null
1393 local p1 = init or null
1394 local t0 = tick()
1395 local h = 0
1396 local c1 = null
1397 local c2 = null
1398 local self = {}
1399 local meta = {}
1400 local function updateconstants()
1401 if s == 0 then
1402 h = 0
1403 c1 = null
1404 c2 = null
1405 elseif d < 0.99999999 then
1406 h = (1 - d * d) ^ 0.5
1407 c1 = p0 - p1
1408 c2 = d / h * c1 + v0 / (h * s)
1409 elseif d < 1.00000001 then
1410 h = 0
1411 c1 = p0 - p1
1412 c2 = c1 + v0 / s
1413 else
1414 h = (d * d - 1) ^ 0.5
1415 local a = -v0 / (2 * s * h)
1416 local b = -(p1 - p0) / 2
1417 c1 = (1 - d / h) * b + a
1418 c2 = (1 + d / h) * b - a
1419 end
1420 end
1421 local function pos(x)
1422 if x < 0.001 then
1423 return p0
1424 end
1425 if s == 0 then
1426 return p0
1427 elseif d < 0.99999999 then
1428 local co = cos(h * s * x)
1429 local si = sin(h * s * x)
1430 local ex = e ^ (d * s * x)
1431 return co / ex * c1 + si / ex * c2 + p1
1432 elseif d < 1.00000001 then
1433 local ex = e ^ (s * x)
1434 return (c1 + s * x * c2) / ex + p1
1435 else
1436 local co = e ^ ((-d - h) * s * x)
1437 local si = e ^ ((-d + h) * s * x)
1438 return c1 * co + c2 * si + p1
1439 end
1440 end
1441 local function vel(x)
1442 if x < 0.001 then
1443 return v0
1444 end
1445 if s == 0 then
1446 return p0
1447 elseif d < 0.99999999 then
1448 local co = cos(h * s * x)
1449 local si = sin(h * s * x)
1450 local ex = e ^ (d * s * x)
1451 return s * (co * h - d * si) / ex * c2 - s * (co * d + h * si) / ex * c1
1452 elseif d < 1.00000001 then
1453 local ex = e ^ (s * x)
1454 return -s / ex * (c1 + (s * x - 1) * c2)
1455 else
1456 local co = e ^ ((-d - h) * s * x)
1457 local si = e ^ ((-d + h) * s * x)
1458 return si * (h - d) * s * c2 - co * (d + h) * s * c1
1459 end
1460 end
1461 local function posvel(x)
1462 if s == 0 then
1463 return p0
1464 elseif d < 0.99999999 then
1465 local co = cos(h * s * x)
1466 local si = sin(h * s * x)
1467 local ex = e ^ (d * s * x)
1468 return co / ex * c1 + si / ex * c2 + p1, s * (co * h - d * si) / ex * c2 - s * (co * d + h * si) / ex * c1
1469 elseif d < 1.00000001 then
1470 local ex = e ^ (s * x)
1471 return (c1 + s * x * c2) / ex + p1, -s / ex * (c1 + (s * x - 1) * c2)
1472 else
1473 local co = e ^ ((-d - h) * s * x)
1474 local si = e ^ ((-d + h) * s * x)
1475 return c1 * co + c2 * si + p1, si * (h - d) * s * c2 - co * (d + h) * s * c1
1476 end
1477 end
1478 updateconstants()
1479 function self.getpv()
1480 return posvel(tick() - t0)
1481 end
1482 function self.setpv(p, v)
1483 local time = tick()
1484 p0, v0 = p, v
1485 t0 = time
1486 updateconstants()
1487 end
1488 function self:accelerate(a)
1489 local time = tick()
1490 local p, v = posvel(time - t0)
1491 p0, v0 = p, v + a
1492 t0 = time
1493 updateconstants()
1494 end
1495 function meta:__index(index)
1496 local time = tick()
1497 if index == "p" then
1498 return pos(time - t0)
1499 elseif index == "v" then
1500 return vel(time - t0)
1501 elseif index == "t" then
1502 return p1
1503 elseif index == "d" then
1504 return d
1505 elseif index == "s" then
1506 return s
1507 end
1508 end
1509 function meta:__newindex(index, value)
1510 local time = tick()
1511 if index == "p" then
1512 p0, v0 = value, vel(time - t0)
1513 elseif index == "v" then
1514 p0, v0 = pos(time - t0), value
1515 elseif index == "t" then
1516 p0, v0 = posvel(time - t0)
1517 p1 = value
1518 elseif index == "d" then
1519 if value == nil then
1520 warn("nil value for d")
1521 warn(debug.traceback())
1522 value = d
1523 end
1524 p0, v0 = posvel(time - t0)
1525 d = value
1526 elseif index == "s" then
1527 if value == nil then
1528 warn("nil value for s")
1529 warn(debug.traceback())
1530 value = s
1531 end
1532 p0, v0 = posvel(time - t0)
1533 s = value
1534 elseif index == "a" then
1535 local p, v = posvel(time - t0)
1536 p0, v0 = p, v + value
1537 end
1538 t0 = time
1539 updateconstants()
1540 end
1541 return setmt(self, meta)
1542 end
1543 end
1544 do
1545 local nspring = {}
1546 physics.nspring = nspring
1547 local tick = tick
1548 local setmt = setmetatable
1549 local cos = math.cos
1550 local sin = math.sin
1551 local cosh = math.cosh
1552 local sinh = math.sinh
1553 local e = 2.718281828459045
1554 function nspring.new(n, d, s)
1555 local null = {}
1556 for i = 1, n do
1557 null[i] = 0
1558 end
1559 local t0 = tick()
1560 local p0 = null
1561 local v0 = null
1562 local p1 = null
1563 local d = d or 1
1564 local s = s or 1
1565 local self = {}
1566 local meta = {}
1567 local function getpv(w)
1568 local t = s * (w - t0)
1569 local d2 = d * d
1570 local h, si, co
1571 if d2 < 1 then
1572 h = (1 - d2) ^ 0.5
1573 co, si = cos(h * t), sin(h * t)
1574 elseif d2 == 1 then
1575 h = 1
1576 co, si = 1, t
1577 else
1578 h = (d2 - 1) ^ 0.5
1579 co, si = cosh(h * t), sinh(h * t)
1580 end
1581 local exp = e ^ (-d * t)
1582 local a0 = exp * (h * co + d * si) / h
1583 local a1 = 1 - exp * (h * co + d * si) / h
1584 local a2 = exp * si / (h * s)
1585 local b0 = -exp * si * s / h
1586 local b1 = exp * si * s / h
1587 local b2 = exp * (h * co - d * si) / h
1588 local p = {}
1589 local v = {}
1590 for i = 1, n do
1591 p[i] = a0 * p0[i] + a1 * p1[i] + a2 * v0[i]
1592 v[i] = b0 * p0[i] + b1 * p1[i] + b2 * v0[i]
1593 end
1594 return p, v
1595 end
1596 function self.setpv(p, v)
1597 t0 = tick()
1598 p0 = p
1599 v0 = v
1600 end
1601 function meta:__index(index)
1602 local time = tick()
1603 if index == "p" then
1604 local p, v = getpv(time)
1605 return p
1606 elseif index == "v" then
1607 local p, v = getpv(time)
1608 return v
1609 elseif index == "t" then
1610 return p1
1611 elseif index == "d" then
1612 return d
1613 elseif index == "s" then
1614 return s
1615 elseif index == "n" then
1616 return n
1617 end
1618 end
1619 function meta:__newindex(index, value)
1620 local time = tick()
1621 if index == "p" then
1622 local p, v = getpv(time)
1623 p0 = value
1624 v0 = v
1625 elseif index == "v" then
1626 local p, v = getpv(time)
1627 p0 = p
1628 v0 = value
1629 elseif index == "t" then
1630 local p, v = getpv(time)
1631 p0 = p
1632 v0 = v
1633 p1 = value
1634 elseif index == "d" then
1635 local p, v = getpv(time)
1636 p0 = p
1637 v0 = v
1638 d = value
1639 elseif index == "s" then
1640 local p, v = getpv(time)
1641 p0 = p
1642 v0 = v
1643 s = value
1644 elseif index == "n" then
1645 local p, v = getpv(time)
1646 p0 = p
1647 v0 = v
1648 for i = n + 1, value do
1649 p0[i] = 0
1650 v0[i] = 0
1651 p1[i] = 0
1652 end
1653 n = value
1654 end
1655 t0 = time
1656 end
1657 return setmt(self, meta)
1658 end
1659 end
1660 local err = 1.0E-10
1661 local function solve(a, b, c, d, e)
1662 if not a then
1663 return
1664 elseif a > -err and a < err then
1665 return solve(b, c, d, e)
1666 end
1667 if e then
1668 local k = -b / (4 * a)
1669 local p = (8 * a * c - 3 * b * b) / (8 * a * a)
1670 local q = (b * b * b + 8 * a * a * d - 4 * a * b * c) / (8 * a * a * a)
1671 local r = (16 * a * a * b * b * c + 256 * a * a * a * a * e - 3 * a * b * b * b * b - 64 * a * a * a * b * d) / (256 * a * a * a * a * a)
1672 local h0, h1, h2 = solve(1, 2 * p, p * p - 4 * r, -q * q)
1673 local s = h2 or h0
1674 if s < err then
1675 local f0, f1 = solve(1, p, r)
1676 if not f1 or f1 < 0 then
1677 return
1678 else
1679 local f = f1 ^ 0.5
1680 return k - f, k + f
1681 end
1682 else
1683 local h = s ^ 0.5
1684 local f = (h * h * h + h * p - q) / (2 * h)
1685 if f > -err and f < err then
1686 return k - h, k
1687 else
1688 local r0, r1 = solve(1, h, f)
1689 local r2, r3 = solve(1, -h, r / f)
1690 if r0 and r2 then
1691 return k + r0, k + r1, k + r2, k + r3
1692 elseif r0 then
1693 return k + r0, k + r1
1694 elseif r2 then
1695 return k + r2, k + r3
1696 else
1697 return
1698 end
1699 end
1700 end
1701 elseif d then
1702 local k = -b / (3 * a)
1703 local p = (3 * a * c - b * b) / (9 * a * a)
1704 local q = (2 * b * b * b - 9 * a * b * c + 27 * a * a * d) / (54 * a * a * a)
1705 local r = p * p * p + q * q
1706 local s = r ^ 0.5 + q
1707 if s > -err and s < err then
1708 if q < 0 then
1709 return k + (-2 * q) ^ 0.3333333333333333
1710 else
1711 return k - (2 * q) ^ 0.3333333333333333
1712 end
1713 elseif r < 0 then
1714 local m = (-p) ^ 0.5
1715 local d = atan2((-r) ^ 0.5, q) / 3
1716 local u = m * cos(d)
1717 local v = m * sin(d)
1718 return k - 2 * u, k + u - 1.7320508075688772 * v, k + u + 1.7320508075688772 * v
1719 elseif s < 0 then
1720 local m = -(-s) ^ 0.3333333333333333
1721 return k + p / m - m
1722 else
1723 local m = s ^ 0.3333333333333333
1724 return k + p / m - m
1725 end
1726 elseif c then
1727 local k = -b / (2 * a)
1728 local u2 = k * k - c / a
1729 if u2 < 0 then
1730 return
1731 else
1732 local u = u2 ^ 0.5
1733 return k - u, k + u
1734 end
1735 elseif b then
1736 return -b / a
1737 else
1738 return
1739 end
1740 end
1741 physics.solve = solve
1742 local minpos = function(a, b, c, d)
1743 if a and a >= 0 then
1744 return a
1745 elseif b and b >= 0 then
1746 return b
1747 elseif c and c >= 0 then
1748 return c
1749 elseif d and d >= 0 then
1750 return d
1751 end
1752 end
1753 physics.minpos = minpos
1754 local function minposroot(a, b, c, d, e)
1755 return minpos(solve(a, b, c, d, e))
1756 end
1757 physics.minposroot = minposroot
1758 function physics.cpoint_traj_point(v, a, r)
1759 local a0 = -2 * dot(r, v)
1760 local a1 = 2 * (dot(v, v) - dot(a, r))
1761 local a2 = 3 * dot(a, v)
1762 local a3 = dot(a, a)
1763 local t = minpos(solve(a3, a2, a1, a0))
1764 if t then
1765 return t, t * v + t * t / 2 * a
1766 end
1767 end
1768 function physics.simple_trajectory(s, a, r)
1769 local a0 = 4 * dot(r, r)
1770 local a1 = -4 * (dot(a, r) + s * s)
1771 local a2 = dot(a, a)
1772 local u = minpos(solve(a2, a1, a0))
1773 if u then
1774 local t = u ^ 0.5
1775 return r / t - t / 2 * a
1776 end
1777 end
1778 function physics.trajectory(pp, pv, pa, tp, tv, ta, s)
1779 local rp = tp - pp
1780 local rv = tv - pv
1781 local ra = ta - pa
1782 local t0, t1, t2, t3 = solve(dot(ra, ra) / 4, dot(ra, rv), dot(ra, rp) + dot(rv, rv) - s * s, 2 * dot(rp, rv), dot(rp, rp))
1783 if t0 and t0 > 0 then
1784 return ra * t0 / 2 + tv + rp / t0, t0
1785 elseif t1 and t1 > 0 then
1786 return ra * t1 / 2 + tv + rp / t1, t1
1787 elseif t2 and t2 > 0 then
1788 return ra * t2 / 2 + tv + rp / t2, t2
1789 elseif t3 and t3 > 0 then
1790 return ra * t3 / 2 + tv + rp / t3, t3
1791 end
1792 end
1793end
1794print("Loading particle module")
1795do
1796 local setmt = setmetatable
1797 local remove = table.remove
1798 local tick = tick
1799 local new = Instance.new
1800 local c3 = Color3.new
1801 local ns = NumberSequence.new
1802 local v3 = Vector3.new
1803 local cf = CFrame.new
1804 local ray = Ray.new
1805 local nv = v3()
1806 local nc = cf()
1807 local dot = nv.Dot
1808 local ptos = nc.pointToObjectSpace
1809 local vtws = nc.vectorToWorldSpace
1810 local workspace = game.Workspace
1811 local camera = workspace.CurrentCamera
1812 local localplayer = game:GetService("Players").LocalPlayer
1813 local playergui = localplayer:WaitForChild("PlayerGui")
1814 local raycast = workspace.FindPartOnRayWithIgnoreList
1815 local raycastwl = workspace.FindPartOnRayWithWhitelist
1816 local ffc = game.FindFirstChild
1817 local players = game:GetService("Players")
1818 local particles = {}
1819 local removelist = {}
1820 local screen = ffc(playergui, "ScreenGui") or new("ScreenGui", playergui)
1821 local time = tick()
1822 local camcf = camera.CFrame
1823 local newbeam
1824 do
1825 local why = Instance.new("Part")
1826 why.Anchored = true
1827 why.Transparency = 1
1828 why.CanCollide = false
1829 why.Size = Vector3.new()
1830 why.CFrame = CFrame.new()
1831 why.Parent = game.Workspace
1832 function newbeam(w0)
1833 local t0, p0, v0
1834 local t1, p1, v1 = tick(), ptos(camcf, w0)
1835 local attach0 = Instance.new("Attachment", why)
1836 local attach1 = Instance.new("Attachment", why)
1837 local beam = Instance.new("Beam", why)
1838 beam.Attachment0 = attach0
1839 beam.Attachment1 = attach1
1840 beam.Segments = 16
1841 beam.TextureSpeed = 0
1842 beam.Transparency = NumberSequence.new(0)
1843 beam.FaceCamera = true
1844 local function update(w2, t2, size, bloom, brightness)
1845 local t2 = tick()
1846 local p2 = ptos(camcf, w2)
1847 local v2
1848 if t0 then
1849 v2 = 2 / (t2 - t1) * (p2 - p1) - (p2 - p0) / (t2 - t0)
1850 else
1851 v2 = (p2 - p1) / (t2 - t1)
1852 v1 = v2
1853 end
1854 t0, v0, p0 = t1, v1, p1
1855 t1, v1, p1 = t2, v2, p2
1856 local dt = t1 - t0
1857 local m0 = v0.magnitude
1858 local m1 = v1.magnitude
1859 beam.CurveSize0 = dt / 3 * m0
1860 beam.CurveSize1 = dt / 3 * m1
1861 attach0.Position = camcf * p0
1862 attach1.Position = camcf * p1
1863 if m0 > 1.0E-8 then
1864 attach0.Axis = vtws(camcf, v0 / m0)
1865 end
1866 if m1 > 1.0E-8 then
1867 attach1.Axis = vtws(camcf, v1 / m1)
1868 end
1869 local dist0 = -p0.z
1870 local dist1 = -p1.z
1871 if dist0 < 0 then
1872 dist0 = 0
1873 end
1874 if dist1 < 0 then
1875 dist1 = 0
1876 end
1877 local w0 = size + bloom * dist0
1878 local w1 = size + bloom * dist1
1879 local l = (p1 - p0) * v3(1, 1, 0).magnitude
1880 local tr = 1 - 4 * size * size / ((w0 + w1) * (2 * l + w0 + w1)) * brightness
1881 beam.Width0 = w0
1882 beam.Width1 = w1
1883 beam.Transparency = ns(tr)
1884 end
1885 local function remove()
1886 attach0:Destroy()
1887 attach1:Destroy()
1888 beam:Destroy()
1889 end
1890 return beam, update, remove
1891 end
1892 end
1893 function particle.new(prop)
1894 local self = {}
1895 local position = prop.position or nv
1896 local velocity = prop.velocity or nv
1897 local acceleration = prop.acceleration or nv
1898 local culling = prop.culling == nil or prop.culling
1899 local size = prop.size or 1
1900 local bloom = prop.bloom or 0
1901 local brightness = prop.brightness or 1
1902 local cancollide = prop.cancollide == nil or prop.cancollide
1903 local elasticity = prop.elasticity or 0.3
1904 local physicsonly = prop.physicsonly or false
1905 local minexitvelocity = prop.minexitvelocity or 500
1906 local penetrationdepth = prop.penetrationdepth
1907 local visualorigin = prop.visualorigin or position
1908 local visualoffset = visualorigin - position
1909 local penetrationpower = penetrationdepth
1910 local life = tick() + (prop.life or 10)
1911 local physignore = prop.physicsignore or {
1912 workspace.Ignore,
1913 camera,
1914 char.character
1915 }
1916 local onstep = prop.onstep
1917 local ontouch = prop.ontouch
1918 local initpenetrationdepth = penetrationdepth
1919 function self:remove()
1920 removelist[self] = true
1921 end
1922 local part
1923 local bullet, bulletupdate, bulletremove = newbeam(position + visualoffset)
1924 bullet.Texture = "http://www.roblox.com/asset/?id=2650195052"
1925 bullet.LightEmission = 1
1926 bullet.Color = ColorSequence.new(prop.color or c3(1, 1, 1))
1927 self.bullet = bullet
1928 self.bulletupdate = bulletupdate
1929 self.bulletremove = bulletremove
1930 function self.step(dt, time)
1931 if life and time > life then
1932 removelist[self] = true
1933 return
1934 end
1935 do
1936 local position0 = position
1937 local velocity0 = velocity
1938 local dposition = dt * velocity0 + dt * dt / 2 * acceleration
1939 if cancollide then
1940 local hit, enter, norm = raycast(workspace, ray(position0, dposition), physignore)
1941 if hit then
1942 local unit = dposition.unit
1943 local maxextent = hit.Size.magnitude * unit
1944 local _, exit, exitnorm = raycastwl(workspace, ray(enter + maxextent, -maxextent), {hit})
1945 local diff = exit - enter
1946 local dist = dot(unit, diff)
1947 local human = replication.getcharhitinfo(hit, enter, maxextent)
1948 local pass = not hit.CanCollide or hit.Transparency == 1 or human and human.player.TeamColor == localplayer.TeamColor
1949 local exited = false
1950 position = enter + 0.01 * unit
1951 local truedt = dot(dposition, enter - position0) / dot(dposition, dposition) * dt
1952 velocity = velocity0 + truedt * acceleration
1953 if not pass then
1954 if dist < penetrationdepth then
1955 penetrationdepth = human and penetrationdepth or penetrationdepth - dist
1956 exited = true
1957 else
1958 removelist[self] = true
1959 end
1960 end
1961 if ontouch then
1962 ontouch(part, human and human.object or hit, enter, norm, exited and exit, exited and exitnorm, 1, human and human.player)
1963 end
1964 physignore[#physignore + 1] = human and human.character or hit
1965 else
1966 position = position0 + dposition
1967 velocity = velocity0 + dt * acceleration
1968 end
1969 else
1970 position = position0 + dposition
1971 velocity = velocity0 + dt * acceleration
1972 end
1973 end
1974 if onstep then
1975 onstep(part, dt)
1976 end
1977 bulletupdate(position + visualoffset, time, size, bloom, brightness)
1978 end
1979 particles[self] = true
1980 local get = {}
1981 local set = {}
1982 local meta = {}
1983 function meta.__index(table, index)
1984 return get[index]()
1985 end
1986 function meta.__newindex(table, index, value)
1987 return set[index](value)
1988 end
1989 function get.position()
1990 return position
1991 end
1992 function get.velocity()
1993 return velocity
1994 end
1995 function get.acceleration()
1996 return acceleration
1997 end
1998 function get.cancollide()
1999 return cancollide
2000 end
2001 function get.size()
2002 return size
2003 end
2004 function get.bloom()
2005 return bloom
2006 end
2007 function get.brightness()
2008 return brightness
2009 end
2010 function get.color()
2011 return bullet.Color
2012 end
2013 function get.life()
2014 return life - tick()
2015 end
2016 function get.distance()
2017 return 1
2018 end
2019 function get.hitwall()
2020 return penetrationdepth ~= initpenetrationdepth
2021 end
2022 function set.position(p)
2023 position = p
2024 end
2025 function set.velocity(v)
2026 velocity = v
2027 end
2028 function set.acceleration(a)
2029 acceleration = a
2030 end
2031 function set.cancollide(newcancollide)
2032 cancollide = newcancollide
2033 end
2034 function set.size(newsize)
2035 size = newsize
2036 end
2037 function set.bloom(newbloom)
2038 bloom = newbloom
2039 end
2040 function set.brightness(newbrightness)
2041 brightness = newbrightness
2042 end
2043 function set.color(newcolor)
2044 bullet.Color = newcolor
2045 end
2046 function set.life(newlife)
2047 life = tick() + newlife
2048 end
2049 part = setmt(self, meta)
2050 if prop.dt then
2051 self.step(prop.dt, tick())
2052 end
2053 return part
2054 end
2055 function particle.step(dt)
2056 local newtime = tick()
2057 local dt = newtime - time
2058 time = newtime
2059 camcf = camera.CoordinateFrame
2060 for p in next, particles, nil do
2061 if removelist[p] then
2062 removelist[p] = nil
2063 particles[p] = nil
2064 p.bulletremove()
2065 else
2066 p.step(dt, time)
2067 end
2068 end
2069 end
2070 function particle:reset()
2071 screen:ClearAllChildren()
2072 for p in next, particles, nil do
2073 p.bulletremove()
2074 end
2075 particles = {}
2076 removelist = {}
2077 end
2078 screen.AncestryChanged:connect(function()
2079 wait()
2080 screen.Parent = playergui
2081 end)
2082end
2083print("Loading (new) sound module")
2084local audiosystem = require(script["Audio System"])
2085audiosystem.Initialize()
2086print("Loading (old) sound module")
2087do
2088 local random = math.random
2089 local new = Instance.new
2090 local fonts = {}
2091 local free = {}
2092 if doPreloading then
2093 local preloadingFolder = Instance.new("Folder")
2094 preloadingFolder.Parent = workspace
2095 preloadingFolder.Name = "Preloading"
2096 end
2097 function sound.load(name, ...)
2098 local font = {
2099 ...
2100 }
2101 for i = 1, #font do
2102 font[i] = "rbxassetid://" .. font[i]
2103 if doPreloading then
2104 local newsound = Instance.new("Sound")
2105 newsound.Parent = workspace:FindFirstChild("Preloading")
2106 newsound.SoundId = font[i]
2107 end
2108 end
2109 fonts[name] = font
2110 end
2111 function sound.play(name, volume, pitch, parent, onDestroy, isLooped, destroySound)
2112 local font = fonts[name]
2113 if font then
2114 do
2115 local soundobject
2116 if #free == 0 then
2117 soundobject = new("Sound")
2118 soundobject.Ended:connect(function()
2119 free[#free + 1] = soundobject
2120 soundobject.Parent = workspace
2121 end)
2122 else
2123 soundobject = free[#free]
2124 free[#free] = nil
2125 end
2126 soundobject.SoundId = font[random(1, #font)]
2127 soundobject.Volume = volume or 1
2128 soundobject.Pitch = pitch or 1
2129 soundobject.Looped = isLooped
2130 soundobject.Parent = parent or workspace
2131 if onDestroy then
2132 soundobject.PlayOnRemove = true
2133 else
2134 soundobject:Play()
2135 end
2136 end
2137 end
2138 end
2139 sound.load("ui_begin", 2201625166)
2140 sound.load("ui_blink", 2201638398, 2201628272, 2201638578, 2201645683, 2201638926, 2201628742)
2141 sound.load("ui_typeoutwhoosh", 2201650206)
2142 sound.load("ui_typeout", 2201663791, 2201663994, 2201664220, 2201664369, 2201664545, 2201664693)
2143 sound.load("ui_smallaward", 2201705675)
2144 sound.load("equipCloth", 873041870, 873041900, 873041920, 873041944, 873041967, 873041996)
2145 sound.load("equipGear", 873042033, 873042054, 873042146, 873042186, 873042220, 873042247)
2146 sound.load("smallSharp", 1073249423, 1073249467, 1073249515)
2147 sound.load("smallSharpEquip", 1073252883, 1073252922)
2148 sound.load("bigSharp", 1073259492, 1073259546)
2149 sound.load("bigSharpEquip", 1073259576)
2150 sound.load("saber", 1073290506, 1073290552, 1073290611)
2151 sound.load("saberEquip", 1073290296, 1073290384, 1073290458)
2152 sound.load("saberLoop", 1073293116)
2153 sound.load("smallBluntEquip", 1073355154)
2154 sound.load("bigBluntEquip", 1073355392)
2155 sound.load("bigBlunt", 1073356333, 1073356365, 1073356402)
2156 sound.load("smallBlunt", 1073356781)
2157 sound.load("aimCloth", 873073597, 873073657, 873073703, 873073749, 873073824, 873073853)
2158 sound.load("aimGear", 873073890, 873073947, 873073999, 873074053, 873074075, 873074102)
2159 sound.load("parkour", 873084310, 873084337, 873084366, 873084394, 873084419, 873084440)
2160 sound.load("stanceProne", 619647373, 619647453)
2161 sound.load("stanceStandCrouch", 619647649, 619649245, 619649367)
2162 sound.load("slideStart", 873104808, 873104834, 873104858, 873104886, 873104915, 873104940)
2163 sound.load("slideEnd", 873101789, 873101811, 873101828)
2164 sound.load("heartBeatIn", 635546179)
2165 sound.load("heartBeatOut", 635546243)
2166 sound.load("useScope", 635546067)
2167 sound.load("killshot", 898398768, 898398730, 898398743)
2168 sound.load("headshotkill", 898398768, 898398785, 898398795, 898398809, 898398817, 898398837)
2169 sound.load("crackSmall", 873119768, 873119788, 873119811, 873119845, 873119886, 873119904)
2170 sound.load("crackBig", 873119597, 873119653, 873119679, 873119703, 873119724, 873119744)
2171 sound.load("whizz", 873121840, 873121858, 873121876, 873121896, 873121913, 873121936)
2172 sound.load("1PsniperBass", 725750810, 725750891, 725750973)
2173 sound.load("1PsniperEcho", 725751043, 725751110, 725751178)
2174 sound.load("fragClose", 873196488, 873196525, 873196559, 873196591, 873196633, 873196678)
2175 sound.load("fragMed", 873196719, 873196759, 873196789, 873196821, 873196855, 873196883, 873196918, 873196944)
2176 sound.load("fragFar", 873196972, 873196997, 873197013, 873197044, 873197083, 873197117)
2177 sound.load("friendly_concreterun", 738449694, 738449739, 738449789, 738449845, 738449901, 738449961)
2178 sound.load("friendly_concretewalk", 738450012, 738450072, 738450121, 738450173, 738450221, 738450271)
2179 sound.load("friendly_concretescuff", 738476779, 738476835, 738476883, 738476924)
2180 sound.load("friendly_grassrun", 738484818, 738484890, 738484962, 738485221, 738485290, 738485364)
2181 sound.load("friendly_grasswalk", 738486870, 738486925, 738486971, 738487026, 738487059, 738487106)
2182 sound.load("friendly_grassscuff", 738488265, 738488385, 738488447, 738488512)
2183 sound.load("friendly_woodrun", 739361221, 739361264, 739361281, 739361317, 739361357, 739361379)
2184 sound.load("friendly_woodwalk", 739361404, 739361426, 739361445, 739361473, 739361503, 739361526)
2185 sound.load("friendly_woodscuff", 739361547, 739361572, 739361584, 739361608)
2186 sound.load("friendly_sandrun", 743048910, 743048927, 743048941, 743048953, 743048965, 743048979)
2187 sound.load("friendly_sandwalk", 743049002, 743049031, 743049053, 743049073, 743049085, 743049103)
2188 sound.load("friendly_sandscuff", 743049123, 743049139, 743049153, 743049162)
2189 sound.load("friendly_metalrun", 744281043, 744281081, 744281118, 744281156, 744281205, 744281233)
2190 sound.load("friendly_metalwalk", 744281257, 744281287, 744281319, 744281350, 744281374, 744281411)
2191 sound.load("friendly_metalscuff", 758169120, 758169193, 758169297, 758169399)
2192 sound.load("concreteLand", 623307723, 623307791, 623307897)
2193 sound.load("grassLand", 623322852, 623322902, 623322960)
2194 sound.load("sandLand", 623308020, 623322719, 623322784)
2195 sound.load("woodLand", 623329224, 623329303, 623329368)
2196 sound.load("metalLand", 866618834, 866618870, 866618897, 866618921)
2197 sound.load("landHard", 866638867)
2198 sound.load("landNearDeath", 866639973)
2199 sound.load("enemy_concreterun", 739281446, 739281465, 739281494, 739281525, 739281543, 739281565)
2200 sound.load("enemy_concretewalk", 739281325, 739281342, 739281360, 739281381, 739281395, 739281423)
2201 sound.load("enemy_woodrun", 739377453, 739377475, 739377503, 739377526, 739377546, 739377556)
2202 sound.load("enemy_woodwalk", 739377579, 739377595, 739377625, 739377652, 739377685, 739377713)
2203 sound.load("enemy_grassrun", 739805543, 739805588, 739805641, 739805681, 739805724, 739805762)
2204 sound.load("enemy_grasswalk", 739805800, 739805889, 739805996, 739806047, 739806110, 739806155)
2205 sound.load("enemy_sandrun", 744274870, 744274901, 744274936, 744274967, 744275010, 744275043)
2206 sound.load("enemy_sandwalk", 744275075, 744275099, 744275126, 744275156, 744275192, 744275220)
2207 sound.load("enemy_metalrun", 758173026, 758173133, 758173185, 758173250, 758173441, 758173516)
2208 sound.load("enemy_metalwalk", 758173608, 758173682, 758173759, 758173891, 758173986, 758174065)
2209 sound.load("movement_gearsmall", 677006227, 677006264, 677006302, 677006342, 677006383, 677007056, 677007096, 677007128)
2210 sound.load("movement_gearbig", 677010268, 677010313, 677010351, 677010399, 677010436, 677010482, 677010520, 677010549)
2211 sound.load("movement_clothrun", 724561895, 724561958, 724561997, 724562031)
2212 sound.load("movement_clothwalk", 724559173, 724559198, 724559218, 724559241)
2213 sound.load("movement_base", 676998794, 676998859, 676998915, 676998993, 676999050, 676999094, 676999145, 676999188, 676999245, 676999327, 676999356, 676999395)
2214 sound.load("imp_concrete", 871701076, 871701134, 871701190, 871701241, 871701297, 871701346)
2215 sound.load("imp_metal", 871704182, 871704259, 871704297, 871704329, 871704362, 871704395)
2216 sound.load("imp_wood", 871705143, 871705174, 871705195, 871705217, 871705237, 871705264)
2217 sound.load("imp_grass", 871709869, 871709832, 871709789, 871709755, 871709708, 871709643)
2218 sound.load("wizz", 342190005, 342190012, 342190017, 342190024)
2219 sound.load("snap", 342190488, 342190495, 342190504, 342190510)
2220 sound.load("woodhit", 342204157, 342204164, 342204170, 342204175)
2221 sound.load("stonehit", 342204189, 342204194, 342204197, 342204203)
2222 sound.load("metalhit", 342204233, 342204240, 342204244, 342204250)
2223 sound.load("woodstep", 169160364)
2224 sound.load("hardstep", 135923526, 342422087, 131436155)
2225 sound.load("softstep", 134456884)
2226 sound.load("fullmetalstep", 342421947, 342421958, 342421973, 342421997)
2227 sound.load("hollowmetalstep", 342421947, 342421958, 342421973, 342421997)
2228 sound.load("metalshell", 342423812, 342423826, 342423844, 342423860)
2229 sound.load("shotgunshell", 342423873, 342423885)
2230 if doPreloading then
2231 sound.load("dev_gunfiresounds_all", 1273918690, 1273918690, 724596714, 584682946, 1009481525, 584682946, 898378539, 614762296, 1007401525, 898468760, 725750543, 620716624, 1660445316, 617413497, 1421516679, 649401969, 1984752916, 620783779, 709722701, 620600621, 1165374500, 1165354061, 1421545840, 1001706451, 613361124, 1007472726, 752725963, 1006015924, 631985687, 898199265, 649184310, 1287077827, 649184310, 649184310, 620716624, 620716624, 600251621, 620716624, 620716624, 1311401092, 620716624, 877524800, 645435484, 645435484, 896335161, 709722701, 1473988039, 724567058, 644918642, 667766809, 600251621, 1287077827, 627851499, 667766809, 898183173, 649395924, 644918642, 696412604, 1287077827, 200901180, 873129141, 631924917, 620742805, 584682946, 620742805, 1501345060, 1132403352, 601306614, 877483245, 841877591, 842030200, 877451192, 725750543, 1007410280, 1543583455, 221793497, 1132403352, 873173851, 696472981, 652680409, 620600621)
2232 game:GetService("ContentProvider"):PreloadAsync(workspace:FindFirstChild("Preloading"):GetChildren())
2233 end
2234end
2235globalsound = sound
2236globalnetwork = network
2237globalreplication = replication
2238print("Loading effects module")
2239do
2240 local wfc = game.WaitForChild
2241 local ffc = game.FindFirstChild
2242 local ud2 = UDim2.new
2243 local v3 = Vector3.new
2244 local nv = v3()
2245 local cf = CFrame.new
2246 local angles = CFrame.Angles
2247 local deg = math.pi / 180
2248 local random = math.random
2249 local color = Color3.new
2250 local colorseq = ColorSequence.new
2251 local spawn = function(F)
2252 coroutine.resume(coroutine.create(F))
2253 end
2254 local ray = Ray.new
2255 local raycast = workspace.FindPartOnRayWithIgnoreList
2256 local debris = game.Debris
2257 local new = Instance.new
2258 local dot = nv.Dot
2259 local nc = cf()
2260 local vtws = nc.vectorToWorldSpace
2261 local player = game:GetService("Players").LocalPlayer
2262 local light = game.Lighting
2263 local pgui = player.PlayerGui
2264 local repeffects = game.ReplicatedStorage.Effects
2265 local smoke = repeffects.Smoke
2266 local hole = repeffects.Hole
2267 local flash = repeffects.Muzzle
2268 local shell = repeffects.Shell
2269 local blood = repeffects.Blood
2270 local bloodsplat = repeffects.BloodSplat
2271 local ignore = workspace.Ignore
2272 local mapbloom = wfc(light, "MapBloom")
2273 local mapray = wfc(light, "MapRay")
2274 local mapsat = wfc(light, "MapSaturation")
2275 local smokelist = {}
2276 local holelist = {}
2277 local flashlist = {}
2278 local shelllist = {}
2279 local impactpool = {}
2280 local effectobjects = repeffects.effectobjects
2281 local materialtype = Enum.Material
2282 local materiallist = {
2283 [Enum.Material.Cobblestone] = {
2284 185234383,
2285 185234399,
2286 185234373,
2287 185234412
2288 },
2289 [Enum.Material.Wood] = {
2290 185238181,
2291 185238234,
2292 185238224,
2293 185238210,
2294 185238204
2295 },
2296 [Enum.Material.Brick] = {
2297 185237818,
2298 185237842,
2299 185237826,
2300 185237805
2301 },
2302 [Enum.Material.Plastic] = {
2303 185238152,
2304 185237945,
2305 185237930
2306 },
2307 [Enum.Material.Concrete] = {
2308 185237894,
2309 185237879,
2310 185237865,
2311 185237853
2312 },
2313 Tile = {
2314 185238332,
2315 185238308,
2316 185238298,
2317 185238288,
2318 185238271,
2319 185238257
2320 }
2321 }
2322 local splatter
2323 do
2324 local sort = table.sort
2325 local random = math.random
2326 local log = math.log
2327 local cos = math.cos
2328 local sin = math.sin
2329 local tau = 2 * math.pi
2330 local function gaussian()
2331 local r0 = 1 - random()
2332 local r1 = random() * tau
2333 local l = (-2 * log(r0)) ^ 0.5
2334 return l * cos(r1), l * sin(r1)
2335 end
2336 local function exponential()
2337 return -log(1 - random())
2338 end
2339 local boxn = {
2340 v3(1, 0, 0),
2341 v3(-1, 0, 0),
2342 v3(0, 1, 0),
2343 v3(0, -1, 0),
2344 v3(0, 0, 1),
2345 v3(0, 0, -1)
2346 }
2347 local boxl = {
2348 0.5,
2349 0.5,
2350 0.5,
2351 0.5,
2352 0.5,
2353 0.5
2354 }
2355 local function transform_mesh(meshn, meshl, cframe, size)
2356 local newn = {}
2357 local newl = {}
2358 for i = 1, #meshn do
2359 local n = meshn[i]
2360 local l = meshl[i]
2361 local tn = vtws(cframe, n / size).unit
2362 local tl = dot(cframe * (l * n * size), tn)
2363 newn[i] = tn
2364 newl[i] = tl
2365 end
2366 return newn, newl
2367 end
2368 local function distance_o_1(an, al, o)
2369 local oan = dot(o, an)
2370 return oan - al
2371 end
2372 local function distance_o_2(an, al, bn, bl, o)
2373 local anbn = dot(an, bn)
2374 local oan = dot(o, an)
2375 local obn = dot(o, bn)
2376 local m = (1 - anbn * anbn) ^ 0.5
2377 return (bl - al * anbn + anbn * oan - obn) / m
2378 end
2379 local function dist_from_edge(meshn, meshl, o)
2380 local besta
2381 local bestd = -1 / 0
2382 for i = 1, #meshn do
2383 local an = meshn[i]
2384 local al = meshl[i]
2385 local d = distance_o_1(an, al, o)
2386 if bestd < d then
2387 besta = i
2388 bestd = d
2389 end
2390 end
2391 if not besta then
2392 return 1 / 0
2393 end
2394 local an = meshn[besta]
2395 local al = meshl[besta]
2396 local r = 1 / 0
2397 for i = 1, #meshn do
2398 if i ~= besta then
2399 local bn = meshn[i]
2400 local bl = meshl[i]
2401 local d = distance_o_2(an, al, bn, bl, o)
2402 if r > d then
2403 r = d
2404 end
2405 end
2406 end
2407 return r
2408 end
2409 local meshcache = {}
2410 local function getmesh(part)
2411 local cache = meshcache[part]
2412 if cache then
2413 return cache.meshn, cache.meshl
2414 else
2415 do
2416 local cframe = part.CFrame
2417 local size = part.Size
2418 local meshn, meshl = transform_mesh(boxn, boxl, part.CFrame, part.Size)
2419 meshcache[part] = {meshn = meshn, meshl = meshl}
2420 local event
2421 event = part.Changed:connect(function()
2422 meshcache[part] = nil
2423 event:disconnect()
2424 end)
2425 return meshn, meshl
2426 end
2427 end
2428 end
2429 local function max_radius(part, pos)
2430 local meshn, meshl = getmesh(part)
2431 return dist_from_edge(meshn, meshl, pos)
2432 end
2433 local spartpool = {}
2434 local function getspart()
2435 local pooledpart = spartpool[#spartpool]
2436 if pooledpart then
2437 spartpool[#spartpool] = nil
2438 return pooledpart
2439 else
2440 local spart = Instance.new("Part")
2441 spart.Shape = "Cylinder"
2442 spart.Anchored = true
2443 spart.CanCollide = false
2444 spart.BrickColor = BrickColor.new("Crimson")
2445 return spart
2446 end
2447 end
2448 local function retirespart(part)
2449 spartpool[#spartpool + 1] = part
2450 end
2451 local function sortandmerge(slist, ulist, lt)
2452 sort(ulist, lt)
2453 local mlist = {}
2454 local m = #slist
2455 local n = #ulist
2456 local i = 1
2457 local j = 1
2458 local k = 0
2459 while m >= i and n >= j do
2460 k = k + 1
2461 local a = slist[i]
2462 local b = ulist[j]
2463 if lt(a, b) then
2464 i = i + 1
2465 mlist[k] = a
2466 else
2467 j = j + 1
2468 mlist[k] = b
2469 end
2470 end
2471 for l = i, m do
2472 k = k + 1
2473 mlist[k] = slist[l]
2474 end
2475 for l = j, n do
2476 k = k + 1
2477 mlist[k] = ulist[l]
2478 end
2479 return mlist
2480 end
2481 local queuedsplatters = {}
2482 local queuedretires = {}
2483 local nsplatters = 0
2484 local splatters = {}
2485 local nretires = 0
2486 local retires = {}
2487 local maxbloodt = 1
2488 local compt0 = function(a, b)
2489 return b.t0 < a.t0
2490 end
2491 local compt1 = function(a, b)
2492 return b.t1 < a.t1
2493 end
2494 function effects.setmaxbloodt(newt)
2495 maxbloodt = newt
2496 end
2497 game:GetService("RunService").RenderStepped:connect(function()
2498 debug.profilebegin("blood creation/removal")
2499 local t = tick()
2500 if nsplatters > 0 then
2501 queuedsplatters = sortandmerge(queuedsplatters, splatters, compt0)
2502 nsplatters = 0
2503 splatters = {}
2504 end
2505 for i = #queuedsplatters, 1, -1 do
2506 if maxbloodt / 1000 < tick() - t then
2507 break
2508 end
2509 local splat = queuedsplatters[i]
2510 if t > splat.t0 then
2511 queuedsplatters[i] = nil
2512 local spart = getspart()
2513 local size = splat.size
2514 local part = splat.part
2515 local norm = splat.norm
2516 local pos = splat.pos
2517 local maxsize = 2 * max_radius(part, pos)
2518 if size > maxsize then
2519 size = maxsize
2520 end
2521 local spart = getspart()
2522 spart.Size = v3(0.05, size, size)
2523 spart.CFrame = cf(pos, pos + norm) * angles(0, tau / 4, 0)
2524 spart.Parent = workspace.Ignore
2525 nretires = nretires + 1
2526 retires[nretires] = {
2527 t1 = splat.t1,
2528 spart = spart
2529 }
2530 else
2531 break
2532 end
2533 end
2534 if nretires > 0 then
2535 queuedretires = sortandmerge(queuedretires, retires, compt1)
2536 nretires = 0
2537 retires = {}
2538 end
2539 for i = #queuedretires, 1, -1 do
2540 if maxbloodt / 1000 < tick() - t then
2541 break
2542 end
2543 local retire = queuedretires[i]
2544 if t > retire.t1 then
2545 queuedretires[i] = nil
2546 retire.spart.Parent = nil
2547 retirespart(retire.spart)
2548 else
2549 break
2550 end
2551 end
2552 debug.profileend()
2553 end)
2554 function splatter(splots, avgsize, orig, velocity, spread, dist, ignorelist, life0, life1)
2555 debug.profilebegin("blood initialization")
2556 local ct = tick()
2557 local v = spread * velocity.magnitude
2558 for i = 1, splots do
2559 local r0, r1 = gaussian()
2560 local r2 = gaussian()
2561 local r3 = exponential()
2562 local dir = velocity + v3(v * r0, v * r1, v * r2)
2563 local size = avgsize * r3
2564 local part, pos, norm = raycast(workspace, ray(orig, dist * dir.unit), ignorelist)
2565 if part and part.Name ~= "Window" and part.Transparency ~= 1 then
2566 nsplatters = nsplatters + 1
2567 local t0 = ct + dot(dir, pos - orig) / dot(dir, dir)
2568 local t1 = t0 + random() * (life1 - life0) + life0
2569 splatters[nsplatters] = {
2570 t0 = t0,
2571 t1 = t1,
2572 size = size,
2573 part = part,
2574 norm = norm,
2575 pos = pos
2576 }
2577 end
2578 end
2579 debug.profileend()
2580 end
2581 end
2582 function effects:ejectshell(trigger, guntype, offset)
2583 local shellpart
2584 if #shelllist ~= 0 then
2585 shellpart = shelllist[#shelllist]
2586 shelllist[#shelllist] = nil
2587 else
2588 shellpart = shell:Clone()
2589 end
2590 delay(0.1, function()
2591 shellpart.CFrame = trigger.CFrame * angles((90 + random(-5, 5)) * deg, random(-5, 5) * deg, random(-5, 5) * deg) * offset
2592 shellpart.RotVelocity = v3(random(-5, 5), random(-5, 5), random(-5, 5))
2593 shellpart.Parent = ignore
2594 shellpart.BodyThrust.force = v3(3.5, 0.1, -3)
2595 wait(0.05)
2596 shellpart.BodyThrust.force = v3(-0.5, 0, 0)
2597 wait(0.1)
2598 shellpart.BodyThrust.force = v3(0, 0, 0)
2599 wait(0.1)
2600 shellpart.Velocity = v3()
2601 shellpart.Parent = nil
2602 shelllist[#shelllist + 1] = shellpart
2603 end)
2604 end
2605 function effects:muzzleflash(barrel)
2606 local flashpart
2607 if #flashlist ~= 0 then
2608 flashpart = flashlist[#flashlist]
2609 flashlist[#flashlist] = nil
2610 else
2611 flashpart = flash:Clone()
2612 end
2613 local flare = ffc(flashpart, "Flare")
2614 local spark = ffc(flashpart, "Spark")
2615 if not flare or not spark then
2616 trash.remove(flashpart)
2617 flashpart = flash:Clone()
2618 flare = ffc(flashpart, "Flare")
2619 spark = ffc(flashpart, "Spark")
2620 end
2621 flashpart.Enabled = true
2622 flashpart.Parent = pgui
2623 flashpart.Adornee = barrel
2624 flare.Rotation = random(0, 360)
2625 flare.Size = ud2(0, 20, 0, 20)
2626 flare.Position = ud2(0.5, -10, 0.5, -10)
2627 spark.Rotation = random(0, 360)
2628 spark.Size = ud2(0, 200, 0, 200)
2629 spark.Position = ud2(0.5, -100, 0.5, -100)
2630 spark.Visible = true
2631 flare:TweenSizeAndPosition(ud2(0, 1000, 0, 1000), ud2(0.5, -500, 0.5, -500), "Out", "Sine", 0.2)
2632 spark:TweenSizeAndPosition(ud2(0, 500, 0, 500), ud2(0.5, -250, 0.5, -250), "Out", "Sine", 0.15)
2633 delay(0.05, function()
2634 spark.Visible = false
2635 wait(0.05)
2636 flashpart.Enabled = false
2637 wait(0.5)
2638 flashpart.Parent = nil
2639 flashlist[#flashlist + 1] = flashpart
2640 end)
2641 char:firemuzzlelight()
2642 end
2643 function effects:breakwindow(hit, pos, norm, vel, force, nobulleteffect)
2644 hit.Parent = ignore
2645 network:send("b" .. "r" .. "e" .. "a" .. "k" .. "w" .. "i" .. "n" .. "d" .. "o" .. "w", hit)
2646 if not nobulleteffect then
2647 effects:bullethit(hit, pos, norm, nil, nil, vel, false, false, 3)
2648 end
2649 end
2650 function effects:bloodhit(start, hit, pos, norm, enablesplatter, damage, velocity)
2651 local damage = damage or 20
2652 if damage > 100 then
2653 damage = 100
2654 end
2655 network:send("b" .. "l" .. "o" .. "o" .. "d" .. "h" .. "i" .. "t", start, hit, pos, norm, enablesplatter, damage / 3, velocity)
2656 createblood(start, hit, pos, norm, enablesplatter, damage, velocity)
2657 end
2658 function effects:enablemapshaders(on)
2659 local shaderlist = {mapsat, mapray}
2660 for i = 1, #shaderlist do
2661 if effects.disableshaders then
2662 shaderlist[i].Enabled = false
2663 else
2664 shaderlist[i].Enabled = on
2665 end
2666 end
2667 end
2668 function createblood(start, hit, pos, norm, enablesplatter, damage, velocity)
2669 if input.consoleon or effects.disableblood then
2670 return
2671 end
2672 local size = 1
2673 local ignorelist = {
2674 ignore,
2675 workspace.DeadBody,
2676 workspace.CurrentCamera
2677 }
2678 local pp = game:GetService("Players"):GetPlayers()
2679 for i = 1, #pp do
2680 ignorelist[#ignorelist + 1] = pp[i].Character
2681 end
2682 if enablesplatter then
2683 local damage = damage or 20
2684 local splots = damage / 2
2685 splatter(splots, 0.5, pos, velocity, 0.125, 20, ignorelist, 7, 15)
2686 end
2687 local bloodpart = hole:Clone()
2688 bloodpart.Parent = ignore
2689 bloodpart.CFrame = cf(pos)
2690 bloodpart.Transparency = 1
2691 bloodpart:ClearAllChildren()
2692 local test = repeffects.BloodTest:Clone()
2693 test.Parent = bloodpart
2694 test.Rate = test.Rate * size
2695 test.Enabled = true
2696 spawn(function()
2697 wait(0.1)
2698 test.Enabled = false
2699 end)
2700 debris:AddItem(bloodpart, 3)
2701 end
2702 network:add("createblood", createblood)
2703 local function makeimpact(hit, pos, norm)
2704 local impacttype
2705 if hit.Name == "Terrain" then
2706 impacttype = "ImpactWater"
2707 elseif hit.Material == Enum.Material.Grass then
2708 impacttype = "ImpactGrass"
2709 elseif eventmod.ison() then
2710 impacttype = "ImpactLaser"
2711 else
2712 impacttype = "ImpactDefault"
2713 end
2714 local impact
2715 local pool = impactpool[impacttype]
2716 if not pool then
2717 impactpool[impacttype] = {}
2718 pool = impactpool[impacttype]
2719 end
2720 if #pool == 0 then
2721 impact = effectobjects[impacttype]:Clone()
2722 impact.Parent = ignore
2723 else
2724 impact = pool[#pool]
2725 pool[#pool] = nil
2726 end
2727 impact.CFrame = cf(pos, pos + 2 * norm + vector.random(1))
2728 local pt = impact:GetChildren()
2729 for i = 1, #pt do
2730 if pt[i]:IsA("ParticleEmitter") then
2731 pt[i].Acceleration = v3(5 * (random() - 0.5), pt[i].Acceleration.Y, 5 * (random() - 0.5))
2732 pt[i].EmissionDirection = "Front"
2733 pt[i]:Emit(pt[i].Rate / 10)
2734 end
2735 end
2736 if impacttype == "Impact1" then
2737 impact.effcloud.EmissionDirection = random(0, 5)
2738 end
2739 delay(0.05, function()
2740 pool[#pool + 1] = impact
2741 end)
2742 end
2743 local function makehole(hit, pos, norm)
2744 local holepart
2745 if #holelist ~= 0 then
2746 holepart = holelist[#holelist]
2747 holelist[#holelist] = nil
2748 else
2749 holepart = hole:Clone()
2750 end
2751 holepart:BreakJoints()
2752 holepart.Parent = ignore
2753 holepart.CFrame = cf(pos, pos - norm) * angles(-90 * deg, random(0, 360) * deg, 0)
2754 local materials = materiallist[Enum.Material.Cobblestone]
2755 if materiallist[hit.Material] then
2756 materials = materiallist[hit.Material]
2757 end
2758 local randId = "http://www.roblox.com/asset/?id=" .. materials[random(1, #materials)]
2759 holepart.Decal1.Texture = randId
2760 holepart.Decal2.Texture = randId
2761 delay(10, function()
2762 holepart.Parent = nil
2763 holelist[#holelist + 1] = holepart
2764 end)
2765 end
2766 function effects:bullethit(hit, pos, norm, exit, exitnorm, vel, smokeon, holeon, sparkson)
2767 if hit.Transparency == 1 then
2768 return
2769 end
2770 local showeffects = camera.screencull.sphere(pos, 16)
2771 if sparkson and showeffects and hit.Material ~= Enum.Material.Sand and hit.Material ~= Enum.Material.Grass and hit.Material ~= Enum.Material.Wood then
2772 for i = 1, sparkson * 2 + 1 do
2773 particle.new({
2774 position = pos,
2775 velocity = (vel - 1.2 * norm:Dot(vel) / norm:Dot(norm) * norm) * 0.1 + vector.random(50),
2776 acceleration = v3(0, -196.2, 0),
2777 cancollide = false,
2778 size = 0.1,
2779 brightness = 20 * random(),
2780 color = Color3.new(1, 1, 0.8),
2781 bloom = 0.005 * random(),
2782 life = random() * 0.1,
2783 physicsonly = true
2784 })
2785 end
2786 if exit and exitnorm then
2787 for i = 1, sparkson * 2 + 1 do
2788 particle.new({
2789 position = exit,
2790 velocity = (vel - 1.2 * exitnorm:Dot(vel) / exitnorm:Dot(exitnorm) * exitnorm) * 0.1 + vector.random(50),
2791 acceleration = v3(0, -196.2, 0),
2792 cancollide = false,
2793 size = 0.1,
2794 brightness = 20 * random(),
2795 color = Color3.new(1, 1, 0.8),
2796 bloom = 0.005 * random(),
2797 life = random() * 0.1,
2798 physicsonly = true
2799 })
2800 end
2801 end
2802 end
2803 local light = hit:FindFirstChildOfClass("SpotLight") or hit:FindFirstChildOfClass("PointLight") or hit:FindFirstChildOfClass("SurfaceLight")
2804 if light then
2805 light:Destroy()
2806 for i = 1, 10 do
2807 particle.new({
2808 position = pos,
2809 velocity = norm * 30 + vector.random(10),
2810 acceleration = v3(0, -20, 0),
2811 cancollide = false,
2812 size = 0.1,
2813 brightness = 5 * random(),
2814 color = Color3.new(1, 1, 0.8),
2815 bloom = 0.005 * random(),
2816 life = 2 * random(),
2817 physicsonly = true
2818 })
2819 end
2820 network:send("breaklights", hit)
2821 end
2822 if not effects.disablerobloxparticles and smokeon and showeffects then
2823 makeimpact(hit, pos, norm)
2824 if exit and exitnorm then
2825 makeimpact(hit, exit, exitnorm)
2826 end
2827 end
2828 if holeon and hit.Transparency == 0 and hit.CanCollide then
2829 makehole(hit, pos, norm)
2830 if exit and exitnorm then
2831 makehole(hit, exit, exitnorm)
2832 end
2833 end
2834 end
2835 function effects:reload()
2836 smokelist = {}
2837 holelist = {}
2838 flashlist = {}
2839 shelllist = {}
2840 end
2841 effects:reload()
2842end
2843print("Loading tween module")
2844do
2845 local type = type
2846 local halfpi = math.pi / 2
2847 local acos = math.acos
2848 local sin = math.sin
2849 local cf = CFrame.new
2850 local tos = cf().toObjectSpace
2851 local components = cf().components
2852 local tick = tick
2853 local tweendata = {}
2854 local equations = {
2855 linear = {
2856 p0 = 0,
2857 v0 = 1,
2858 p1 = 1,
2859 v1 = 1
2860 },
2861 smooth = {
2862 p0 = 0,
2863 v0 = 0,
2864 p1 = 1,
2865 v1 = 0
2866 },
2867 accelerate = {
2868 p0 = 0,
2869 v0 = 0,
2870 p1 = 1,
2871 v1 = 1
2872 },
2873 decelerate = {
2874 p0 = 0,
2875 v0 = 1,
2876 p1 = 1,
2877 v1 = 0
2878 },
2879 bump = {
2880 p0 = 0,
2881 v0 = 4,
2882 p1 = 0,
2883 v1 = -4
2884 },
2885 acceleratebump = {
2886 p0 = 0,
2887 v0 = 0,
2888 p1 = 0,
2889 v1 = -6.75
2890 },
2891 deceleratebump = {
2892 p0 = 0,
2893 v0 = 6.75,
2894 p1 = 0,
2895 v1 = 0
2896 }
2897 }
2898 local updater = {}
2899 tween.step = event.new(updater)
2900 function tween.tweencframe(object, index, time, equation, nextcframe)
2901 if tweendata[object] then
2902 tweendata[object]()
2903 end
2904 local t0 = tick()
2905 local p0, v0, p1, v1
2906 if type(equation) == "table" then
2907 p0 = equation[1]
2908 v0 = equation[2]
2909 p1 = equation[3]
2910 v1 = equation[4]
2911 else
2912 local eq = equations[equation]
2913 p0, v0, p1, v1 = eq.p0, eq.v0, eq.p1, eq.v1
2914 end
2915 local interpolator = cframe.interpolator(object[index], nextcframe)
2916 local stop
2917 stop = updater:connect(function()
2918 local u = (tick() - t0) / time
2919 if u > 1 then
2920 object[index] = interpolator(p1)
2921 stop()
2922 tweendata[object] = nil
2923 else
2924 local v = 1 - u
2925 local t = p0 * v * v * v + (3 * p0 + v0) * u * v * v + (3 * p1 - v1) * u * u * v + p1 * u * u * u
2926 object[index] = interpolator(t)
2927 end
2928 end)
2929 tweendata[object] = stop
2930 return stop
2931 end
2932 function tween.freebody(object, index, life, cframe0, velocity0, rotation0, acceleration)
2933 local position0 = cframe0.p
2934 local matrix0 = cframe0 - position0
2935 local tick0 = tick()
2936 local stop
2937 stop = updater:connect(function()
2938 local t = tick() - tick0
2939 if life and t > life then
2940 stop()
2941 trash.remove(object)
2942 end
2943 object[index] = cframe.fromaxisangle(t * rotation0) * matrix0 + position0 + t * velocity0 + t * t * acceleration
2944 end)
2945 return stop
2946 end
2947end
2948print("Loading input module")
2949do
2950 local tick = tick
2951 local lower = string.lower
2952 local nv = Vector3.new()
2953 local userinput = game:GetService("UserInputService")
2954 local abbreviation = {
2955 ButtonX = "x",
2956 ButtonY = "y",
2957 ButtonA = "a",
2958 ButtonB = "b",
2959 ButtonR1 = "r1",
2960 ButtonL1 = "l1",
2961 ButtonR2 = "r2",
2962 ButtonL2 = "l2",
2963 ButtonR3 = "r3",
2964 ButtonL3 = "l3",
2965 ButtonStart = "start",
2966 ButtonSelect = "select",
2967 DPadLeft = "left",
2968 DPadRight = "right",
2969 DPadUp = "up",
2970 DPadDown = "down"
2971 }
2972 input.keyboard = {}
2973 input.keyboard.down = {}
2974 input.keyboard.onkeydown = {}
2975 input.keyboard.onkeyup = {}
2976 input.mouse = {}
2977 input.mouse.Position = nv
2978 input.mouse.down = {}
2979 input.mouse.onbuttondown = {}
2980 input.mouse.onbuttonup = {}
2981 input.mouse.onmousemove = {}
2982 input.mouse.onscroll = {}
2983 input.controller = {}
2984 input.controller.down = {}
2985 input.controller.onbuttondown = {}
2986 input.controller.onbuttonup = {}
2987 input.controller.onintegralmove = {}
2988 input.consoleon = not userinput.KeyboardEnabled
2989 local fireonkeydown = event.new(input.keyboard.onkeydown)
2990 local fireonkeyup = event.new(input.keyboard.onkeyup)
2991 local fireonbuttondown = event.new(input.mouse.onbuttondown)
2992 local fireonbuttonup = event.new(input.mouse.onbuttonup)
2993 local fireonmousemove = event.new(input.mouse.onmousemove)
2994 local fireonscroll = event.new(input.mouse.onscroll)
2995 local fireoncbuttondown = event.new(input.controller.onbuttondown)
2996 local fireoncbuttonup = event.new(input.controller.onbuttonup)
2997 local fireonintegralmove = event.new(input.controller.onintegralmove)
2998 local keymap = {}
2999 local triggerthreshold = 0.2
3000 local stickthreshold = 0.25
3001 local gamepadpos
3002 local triggeron = {}
3003 local typing
3004 function input.iskeydown(key)
3005 return userinput:GetKeysPressed()[key]
3006 end
3007 userinput.TextBoxFocused:connect(function()
3008 typing = true
3009 end)
3010 userinput.TextBoxFocusReleased:connect(function()
3011 typing = false
3012 end)
3013 userinput.InputChanged:connect(function(object)
3014 local type = object.UserInputType.Name
3015 local pos = object.Position
3016 if type == "MouseMovement" then
3017 input.mouse.position = pos
3018 fireonmousemove(object.Delta)
3019 elseif type == "MouseWheel" then
3020 fireonscroll(pos.z)
3021 elseif type == "Gamepad1" then
3022 local key = object.KeyCode.Name
3023 if key == "Thumbstick2" then
3024 local m = pos.magnitude
3025 if m > stickthreshold then
3026 gamepadpos = (1 - stickthreshold / m) / (1 - stickthreshold) * pos
3027 elseif gamepadpos then
3028 gamepadpos = nil
3029 end
3030 elseif key == "ButtonL2" or key == "ButtonR2" then
3031 local abv = abbreviation[key]
3032 if triggerthreshold < pos.z and not input.controller.down[abv] then
3033 local mappedkey = keymap[abv]
3034 if mappedkey then
3035 input.keyboard.down[mappedkey] = tick()
3036 fireonkeydown(mappedkey)
3037 end
3038 input.controller.down[abv] = tick()
3039 fireoncbuttondown(abv)
3040 elseif pos.z < triggerthreshold and input.controller.down[abv] then
3041 local mappedkey = keymap[abv]
3042 if mappedkey then
3043 input.keyboard.down[mappedkey] = nil
3044 fireonkeyup(mappedkey)
3045 end
3046 input.controller.down[abv] = nil
3047 fireoncbuttonup(abv)
3048 end
3049 end
3050 end
3051 end)
3052 userinput.InputBegan:connect(function(object)
3053 if typing or char.health and char.health <= 0 then
3054 return
3055 end
3056 local type = object.UserInputType.Name
3057 if type == "Keyboard" then
3058 local key = lower(object.KeyCode.Name)
3059 input.keyboard.down[key] = tick()
3060 fireonkeydown(key)
3061 elseif type == "Gamepad1" then
3062 local key = abbreviation[object.KeyCode.Name]
3063 if key and key ~= "l2" and key ~= "r2" or not input.controller.down[key] then
3064 local mappedkey = keymap[key]
3065 if mappedkey then
3066 input.keyboard.down[mappedkey] = tick()
3067 fireonkeydown(mappedkey)
3068 end
3069 input.controller.down[key] = tick()
3070 fireoncbuttondown(key)
3071 end
3072 elseif type == "MouseButton1" then
3073 input.mouse.down.left = tick()
3074 fireonbuttondown("left")
3075 elseif type == "MouseButton2" then
3076 input.mouse.down.right = tick()
3077 fireonbuttondown("right")
3078 elseif type == "MouseButton3" then
3079 input.mouse.down.middle = tick()
3080 fireonbuttondown("middle")
3081 end
3082 end)
3083 userinput.InputEnded:connect(function(object)
3084 if typing then
3085 return
3086 end
3087 local type = object.UserInputType.Name
3088 if type == "Keyboard" then
3089 local key = lower(object.KeyCode.Name)
3090 input.keyboard.down[key] = nil
3091 fireonkeyup(key)
3092 elseif type == "Gamepad1" then
3093 local key = abbreviation[object.KeyCode.Name]
3094 if key and key ~= "l2" and key ~= "r2" or input.controller.down[key] then
3095 local mappedkey = keymap[key]
3096 if mappedkey then
3097 input.keyboard.down[mappedkey] = nil
3098 fireonkeyup(mappedkey)
3099 end
3100 input.controller.down[key] = nil
3101 fireoncbuttonup(key)
3102 end
3103 elseif type == "MouseButton1" then
3104 input.mouse.down.left = nil
3105 fireonbuttonup("left")
3106 elseif type == "MouseButton2" then
3107 input.mouse.down.right = nil
3108 fireonbuttonup("right")
3109 elseif type == "MouseButton3" then
3110 input.mouse.down.middle = nil
3111 fireonbuttonup("middle")
3112 end
3113 end)
3114 function input.mouse:hide()
3115 userinput.MouseIconEnabled = false
3116 end
3117 function input.mouse:show()
3118 userinput.MouseIconEnabled = true
3119 end
3120 function input.mouse.visible()
3121 return userinput.MouseIconEnabled
3122 end
3123 function input.mouse:lockcenter()
3124 userinput.MouseBehavior = "LockCenter"
3125 end
3126 function input.mouse:free()
3127 userinput.MouseBehavior = "Default"
3128 end
3129 function input.mouse:lock()
3130 userinput.MouseBehavior = "LockCurrentPosition"
3131 end
3132 function input.controller:map(button, key)
3133 keymap[button] = key
3134 end
3135 function input.controller:unmap(button)
3136 keymap[button] = nil
3137 end
3138 function input.step(dt)
3139 if gamepadpos then
3140 fireonintegralmove(dt * gamepadpos, dt)
3141 end
3142 end
3143end
3144print("Loading animation module")
3145do
3146 local sin = math.sin
3147 local acos = math.acos
3148 local type = type
3149 local next = next
3150 local tick = tick
3151 local cf = CFrame.new
3152 local v3 = vector.new
3153 local nv = v3()
3154 local inverse = CFrame.new().inverse
3155 local tos = CFrame.new().toObjectSpace
3156 local toquaternion = cframe.toquaternion
3157 local clone = game.Clone
3158 local new = Instance.new
3159 local play = new("Sound").Play
3160 local stop = new("Sound").Stop
3161 local equations = {
3162 linear = {
3163 p0 = 0,
3164 v0 = 1,
3165 p1 = 1,
3166 v1 = 1
3167 },
3168 smooth = {
3169 p0 = 0,
3170 v0 = 0,
3171 p1 = 1,
3172 v1 = 0
3173 },
3174 accelerate = {
3175 p0 = 0,
3176 v0 = 0,
3177 p1 = 1,
3178 v1 = 1
3179 },
3180 decelerate = {
3181 p0 = 0,
3182 v0 = 1,
3183 p1 = 1,
3184 v1 = 0
3185 },
3186 bump = {
3187 p0 = 0,
3188 v0 = 4,
3189 p1 = 0,
3190 v1 = -4
3191 },
3192 acceleratebump = {
3193 p0 = 0,
3194 v0 = 0,
3195 p1 = 0,
3196 v1 = -6.75
3197 },
3198 deceleratebump = {
3199 p0 = 0,
3200 v0 = 6.75,
3201 p1 = 0,
3202 v1 = 0
3203 }
3204 }
3205 local function interpolator(c0, c1, t0, dur, eq, pivot)
3206 pivot = pivot or nv
3207 c0 = c0 * cf(pivot)
3208 c1 = c1 * cf(pivot)
3209 local p0, v0, p1, v1
3210 if type(eq) == "table" then
3211 p0, v0, p1, v1 = eq[1], eq[2], eq[3], eq[4]
3212 else
3213 local eq = equations[eq or "smooth"]
3214 p0, v0, p1, v1 = eq.p0, eq.v0, eq.p1, eq.v1
3215 end
3216 return function(t)
3217 t = (t - t0) / dur
3218 t = t < 1 and t or 1
3219 local i = 1 - t
3220 local v = p0 * i * i * i + (3 * p0 + v0) * t * i * i + (3 * p1 - v1) * t * t * i + p1 * t * t * t
3221 return cframe.interpolate(c0, c1, v) * cf(-pivot), 1 == t
3222 end
3223 end
3224 function animation.player(modeldata, sequence)
3225 local interpolators = {}
3226 local framenumber = 1
3227 local t0 = 0
3228 local lasttime = t0
3229 local stdtimescale = sequence.stdtimescale
3230 local timescale = sequence.timescale
3231 local cframes = {}
3232 local lastcframes = {}
3233 local ignore = workspace.Ignore
3234 local player = game:GetService("Players").LocalPlayer
3235 for i, v in next, modeldata, nil do
3236 if v.part then
3237 lastcframes[i] = v.part.CFrame
3238 cframes[i] = v.part.CFrame
3239 end
3240 end
3241 return function(time)
3242 local dt = time - lasttime
3243 lasttime = time
3244 for i = framenumber, #sequence do
3245 local frame = sequence[i]
3246 if time > t0 then
3247 for i = 1, #frame do
3248 local data = frame[i]
3249 local partname = data.part
3250 if not modeldata[partname] then
3251 error("Error in frame: " .. framenumber .. ". " .. partname .. " is not in modeldata")
3252 end
3253 if data.c0 then
3254 interpolators[partname] = nil
3255 modeldata[partname].weld.C0 = data.c0 == "base" and modeldata[partname].basec0 or data.c0
3256 end
3257 if data.c1 then
3258 interpolators[partname] = interpolator(modeldata[partname].weld.C0, data.c1 == "base" and modeldata[partname].basec0 or data.basemult and modeldata[partname].basec0 * data.c1 or data.c1, t0, data.t and data.t * timescale or frame.delay * timescale, data.eq, data.pivot)
3259 end
3260 if data.clone then
3261 if modeldata[data.clone] then
3262 error("Error in frame: " .. framenumber .. ". Cannot clone " .. partname .. ". " .. data.clone .. " already exists.")
3263 end
3264 local part = clone(modeldata[partname].part)
3265 part.Parent = ignore
3266 part:ClearAllChildren()
3267 local tt = modeldata[partname].part:GetChildren()
3268 for i = 1, #tt do
3269 if tt[i]:IsA("Texture") then
3270 local trans = modeldata.camodata[modeldata[partname].part][tt[i]].Transparency
3271 local hackytt = tt[i]:Clone()
3272 hackytt.Transparency = trans
3273 hackytt.Parent = part
3274 elseif tt[i]:IsA("FileMesh") or tt[i]:IsA("CylinderMesh") or tt[i]:IsA("BlockMesh") or tt[i]:IsA("SpecialMesh") then
3275 tt[i]:Clone().Parent = part
3276 end
3277 end
3278 local weld = new("Motor6D", part)
3279 local part0 = data.part0 and modeldata[data.part0].part or modeldata[partname].weld.Part0
3280 weld.Part0 = part0
3281 weld.Part1 = part
3282 weld.C0 = part0.CFrame:inverse() * modeldata[partname].weld.Part0.CFrame * modeldata[partname].weld.C0
3283 modeldata[data.clone] = {
3284 part = part,
3285 weld = weld,
3286 clone = true
3287 }
3288 cframes[data.clone] = cframes[partname]
3289 lastcframes[data.clone] = lastcframes[partname]
3290 end
3291 if data.transparency then
3292 modeldata[partname].part.Transparency = data.transparency
3293 if modeldata.camodata and modeldata.camodata[modeldata[partname].part] then
3294 local tt = modeldata[partname].part:GetChildren()
3295 for i = 1, #tt do
3296 if tt[i]:IsA("Texture") or tt[i]:IsA("Decal") then
3297 local trans = modeldata.camodata[modeldata[partname].part][tt[i]].Transparency
3298 tt[i].Transparency = data.transparency ~= 1 and trans or 1
3299 end
3300 end
3301 end
3302 end
3303 if data.sound then
3304 do
3305 local sound = new("Sound")
3306 if data.soundid then
3307 sound.SoundId = data.soundid
3308 end
3309 if data.v then
3310 sound.Volume = data.v
3311 end
3312 if data.p then
3313 sound.Pitch = data.p
3314 end
3315 if data.tp then
3316 sound.TimePosition = data.tp
3317 else
3318 sound.TimePosition = 0
3319 end
3320 if data.head then
3321 sound.Parent = player.Character.Head
3322 else
3323 sound.Parent = modeldata[partname].part
3324 end
3325 sound:Play()
3326 if data.d then
3327 delay(data.d, function()
3328 sound:Stop()
3329 end)
3330 end
3331 end
3332 end
3333 if data.drop then
3334 if not modeldata[partname].clone then
3335 error("Error in frame: " .. framenumber .. ". Cannot drop " .. partname .. ". Part is not a clone")
3336 end
3337 local lastcf = lastcframes[partname]
3338 local curcf = cframes[partname]
3339 tween.freebody(modeldata[partname].part, "CFrame", timescale / stdtimescale, modeldata[partname].part.CFrame, (curcf.p - lastcf.p) / dt, cframe.toaxisangle(curcf * lastcf:inverse()) / dt, v3(0, -196.2 / stdtimescale * stdtimescale * (timescale * timescale), 0))
3340 trash.remove(modeldata[partname].weld)
3341 modeldata[partname] = nil
3342 interpolators[partname] = nil
3343 end
3344 if data.delete then
3345 trash.remove(modeldata[partname].weld)
3346 trash.remove(modeldata[partname].part)
3347 modeldata[partname] = nil
3348 interpolators[partname] = nil
3349 end
3350 end
3351 t0 = t0 + frame.delay * timescale
3352 framenumber = framenumber + 1
3353 else
3354 break
3355 end
3356 end
3357 for i, v in next, interpolators, nil do
3358 local newcf, stop, t = v(time)
3359 modeldata[i].weld.C0 = newcf
3360 if stop then
3361 interpolators[i] = nil
3362 end
3363 end
3364 for i, v in next, modeldata, nil do
3365 if v.part then
3366 lastcframes[i] = cframes[i]
3367 cframes[i] = v.part.CFrame
3368 end
3369 end
3370 if time > t0 then
3371 for i, v in next, modeldata, nil do
3372 if v.clone then
3373 trash.remove(v.weld)
3374 trash.remove(v.part)
3375 modeldata[i] = nil
3376 end
3377 end
3378 end
3379 return time > t0
3380 end
3381 end
3382 function animation.reset(modeldata, t, keepvisible, resetboltlock)
3383 resetboltlock = resetboltlock or not modeldata.boltlock
3384 local interpolators = {}
3385 for i, v in next, modeldata, nil do
3386 if v.clone then
3387 modeldata[i] = nil
3388 trash.remove(v.weld)
3389 trash.remove(v.part)
3390 else
3391 if not keepvisible and v.part then
3392 v.part.Transparency = v.basetransparency
3393 if modeldata.camodata and modeldata.camodata[v.part] then
3394 local tt = v.part:GetChildren()
3395 for i = 1, #tt do
3396 if tt[i]:IsA("Texture") or tt[i]:IsA("Decal") then
3397 local trans = modeldata.camodata[v.part][tt[i]].Transparency
3398 tt[i].Transparency = trans
3399 end
3400 end
3401 end
3402 end
3403 if v.weld and (i ~= "Bolt" or i == "Bolt" and resetboltlock) then
3404 interpolators[i] = interpolator(v.weld.C0, v.basec0, 0, t or 1)
3405 end
3406 end
3407 end
3408 return function(time)
3409 for i, v in next, interpolators, nil do
3410 if i ~= "Bolt" or i == "Bolt" and resetboltlock then
3411 local newcf, stop = v(time)
3412 modeldata[i].weld.C0 = newcf
3413 end
3414 end
3415 return time > t
3416 end
3417 end
3418end
3419print("Loading chat module")
3420do
3421 local wfc = game.WaitForChild
3422 local ffc = game.FindFirstChild
3423 local ud2 = UDim2.new
3424 local ceil = math.ceil
3425 local cf = CFrame.new
3426 local v3 = Vector3.new
3427 local color = Color3.new
3428 local dot = Vector3.new().Dot
3429 local workspace = workspace
3430 local ray = Ray.new
3431 local new = Instance.new
3432 local rtype = game.IsA
3433 local debris = game.Debris
3434 local sub = string.sub
3435 local len = string.len
3436 local lower = string.lower
3437 local find = string.find
3438 local insert = table.insert
3439 local match = string.match
3440 local player = game:GetService("Players").LocalPlayer
3441 local pgui = player.PlayerGui
3442 local misc = game.ReplicatedStorage.Misc
3443 local msg = wfc(misc, "Msger")
3444 local chatgui = wfc(pgui, "ChatGame")
3445 local chatbox = wfc(chatgui, "TextBox")
3446 local warn = wfc(chatgui, "Warn")
3447 local version = wfc(chatgui, "Version")
3448 local globalchat = wfc(chatgui, "GlobalChat")
3449 local guesttip = wfc(chatgui, "GuestTip")
3450 version.Text = "Server version: " .. updateversion
3451 local admin, moderator
3452 local adminlist = {
3453 525919,
3454 1667819,
3455 5725475,
3456 4337002
3457 }
3458 local moderatorlist = {66366193, 70273584}
3459 local banlist = {}
3460 local canchat = true
3461 local chatspam = 0
3462 local totalspam = 0
3463 local maxchar = 400
3464 local lines = 8
3465 local chatting
3466 local isguest = player.UserId < 0 and not game:GetService("RunService"):IsStudio()
3467 for i = 1, #adminlist do
3468 if adminlist[i] == player.userId then
3469 admin = true
3470 end
3471 end
3472 for i = 1, #moderatorlist do
3473 if moderatorlist[i] == player.userId then
3474 moderator = true
3475 end
3476 end
3477 for i = 1, #banlist do
3478 if banlist[i] == player.Name then
3479 player:kick("Banlist kick")
3480 end
3481 end
3482 network:add("console", function(message)
3483 local mes = msg:Clone()
3484 local mtag = wfc(mes, "Tag")
3485 local offset = 5
3486 mes.Parent = globalchat
3487 mes.Text = "[Console]: "
3488 mes.TextColor3 = Color3.new(0.4, 0.4, 0.4)
3489 mes.Msg.Text = message
3490 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3491 end)
3492 network:add("announce", function(message)
3493 local mes = msg:Clone()
3494 local mtag = wfc(mes, "Tag")
3495 local offset = 5
3496 mes.Parent = globalchat
3497 mes.Text = "[ANNOUNCEMENT]: "
3498 mes.TextColor3 = Color3.new(0.9803921568627451, 0.6509803921568628, 0.10196078431372549)
3499 mes.Msg.Text = message
3500 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3501 end)
3502 network:add("chatted", function(chatter, text, tag, tagcolor, teamchat, chattername)
3503 if teamchat and chatter.TeamColor ~= player.TeamColor then
3504 return
3505 end
3506 local mes = msg:Clone()
3507 local mtag = wfc(mes, "Tag")
3508 mes.Parent = globalchat
3509 local offset = 5
3510 mtag.Text = tag and tag .. " " or ""
3511 if tag then
3512 if string.sub(tag, 0, 1) == "$" then
3513 local imgid = string.sub(tag, 2)
3514 mes.Position = ud2(0.01, 50, 1, 20)
3515 mtag.Staff.Visible = true
3516 mtag.Staff.Image = "rbxassetid://" .. imgid
3517 mtag.Text = " "
3518 else
3519 offset = mtag.TextBounds.x + 5
3520 mes.Position = ud2(0.01, offset, 1, 20)
3521 mtag.Position = ud2(0, -offset + 5, 0, 0)
3522 if tagcolor then
3523 mtag.TextColor3 = tagcolor
3524 end
3525 end
3526 end
3527 mes.Text = chattername .. " : "
3528 mes.TextColor = chatter.TeamColor
3529 mes.Msg.Text = text
3530 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3531 end)
3532 local eval
3533 do
3534 local math = math
3535 local byte = string.byte
3536 local find = string.find
3537 local lparen = byte("(")
3538 local rparen = byte(")")
3539 local add = byte("+")
3540 local sub = byte("-")
3541 local mul = byte("*")
3542 local div = byte("/")
3543 local pow = byte("^")
3544 local mod = byte("%")
3545 local zero = byte("0")
3546 local nine = byte("9")
3547 local dot = byte(".")
3548 local space = byte(" ")
3549 local tab = byte("\t")
3550 local newl = byte("\n")
3551 local arith = {
3552 [add] = function(a, b)
3553 return a + b
3554 end,
3555 [sub] = function(a, b)
3556 return a - b
3557 end,
3558 [mul] = function(a, b)
3559 return a * b
3560 end,
3561 [div] = function(a, b)
3562 return a / b
3563 end,
3564 [pow] = function(a, b)
3565 return a ^ b
3566 end,
3567 [mod] = function(a, b)
3568 return a % b
3569 end
3570 }
3571 local whitespace = {
3572 [space] = true,
3573 [tab] = true,
3574 [newl] = true
3575 }
3576 local function f(eq, i)
3577 local neq = #eq
3578 local n = 0
3579 local op = add
3580 local func, m, x, _
3581 while i <= neq do
3582 local c = byte(eq, i)
3583 if arith[c] then
3584 op = c
3585 elseif c == rparen then
3586 break
3587 elseif whitespace[c] then
3588 else
3589 if c == lparen then
3590 m, i = f(eq, i + 1)
3591 elseif c >= zero and c <= nine or c == dot then
3592 _, i, m = find(eq, "(%d*%.?%d*)", i)
3593 else
3594 _, i, func = find(eq, "(%a*)%(", i)
3595 if i then
3596 x, i = f(eq, i + 1)
3597 m = math[func](x)
3598 else
3599 return
3600 end
3601 end
3602 n = arith[op](n, m)
3603 end
3604 i = i + 1
3605 end
3606 return n, i
3607 end
3608 function eval(eq)
3609 return (f(eq, 1))
3610 end
3611 end
3612 local function findplayer(name, speaker)
3613 if lower(name) == "all" then
3614 local chars = {}
3615 local c = game:GetService("Players"):GetPlayers()
3616 for i = 1, #c do
3617 insert(chars, c[i])
3618 end
3619 return chars
3620 elseif lower(name) == "me" then
3621 return {speaker}
3622 elseif lower(name) == "others" then
3623 local chars = {}
3624 local c = game:GetService("Players"):GetPlayers()
3625 for i = 1, #c do
3626 if c ~= speaker then
3627 insert(chars, c[i])
3628 end
3629 end
3630 return chars
3631 else
3632 local chars = {}
3633 local commalist = {}
3634 local ssn = 0
3635 local lownum = 1
3636 local highestnum = 1
3637 local foundone
3638 while true do
3639 ssn = ssn + 1
3640 if sub(name, ssn, ssn) == "" then
3641 insert(commalist, lownum)
3642 insert(commalist, ssn - 1)
3643 highestnum = ssn - 1
3644 break
3645 end
3646 if string.sub(name, ssn, ssn) == "," then
3647 foundone = true
3648 table.insert(commalist, lownum)
3649 table.insert(commalist, ssn)
3650 lownum = ssn + 1
3651 end
3652 end
3653 if foundone then
3654 for ack = 1, #commalist, 2 do
3655 local cnum = 0
3656 local char
3657 local c = game:GetService("Players"):GetPlayers()
3658 for i = 1, #c do
3659 if find(lower(c[i].Name), sub(lower(name), commalist[ack], commalist[ack + 1] - 1)) == 1 then
3660 char = c[i]
3661 cnum = cnum + 1
3662 end
3663 end
3664 if cnum == 1 then
3665 table.insert(chars, char)
3666 end
3667 end
3668 return #chars ~= 0 and chars or 0
3669 else
3670 local cnum = 0
3671 local char
3672 local c = game:GetService("Players"):GetPlayers()
3673 for i = 1, #c do
3674 if find(lower(c[i].Name), lower(name)) == 1 then
3675 char = {
3676 c[i]
3677 }
3678 cnum = cnum + 1
3679 end
3680 end
3681 return cnum == 1 and char or 0
3682 end
3683 end
3684 end
3685 network:add("printstring", function(...)
3686 local ss = {
3687 ...
3688 }
3689 local s = ""
3690 for i = 1, #s do
3691 s = s .. "\t" .. ss[i]
3692 end
3693 s = s .. "\n"
3694 local i = 0
3695 local lel = ""
3696 for str in string.gmatch(s, [[
3697(^[
3698]*)
3699]]) do
3700 i = i + 1
3701 lel = lel .. "\n" .. str
3702 if i == 64 then
3703 print(lel)
3704 i = 0
3705 lel = ""
3706 end
3707 end
3708 end)
3709 local function newchat()
3710 local message = chatbox.Text
3711 chatbox.Text = "Press '/' or click here to chat"
3712 chatting = false
3713 chatbox.ClearTextOnFocus = true
3714 chatbox.Active = false
3715 if sub(message, 1, 1) == "/" then
3716 network:send("m" .. "o" .. "d" .. "c" .. "m" .. "d", message)
3717 chatbox.Text = "Press '/' or click here to chat"
3718 chatting = false
3719 chatbox.ClearTextOnFocus = true
3720 return
3721 end
3722 message = string.gsub(message, [[
3723
3724+]], "")
3725 message = string.gsub(message, " +", " ")
3726 local teamchat, teamswitch, admincommand
3727 if sub(message, 1, 1) == "%" then
3728 teamchat = true
3729 message = sub(message, 2, len(message))
3730 end
3731 message = string.gsub(message, "{(.-)}", eval)
3732 if chatspam > 5 and not moderator and not admin then
3733 warn.Visible = true
3734 chatspam = chatspam + 1
3735 totalspam = totalspam + 1
3736 warn.Text = "You have been blocked temporarily for spamming. WARNING : " .. totalspam .. " out of 3"
3737 if totalspam > 3 then
3738 netkick("player was kicked for repeated spamming")
3739 end
3740 delay(5, function()
3741 chatspam = chatspam - 5
3742 warn.Visible = false
3743 end)
3744 return
3745 end
3746 local teamtype
3747 if network:fetch("s" .. "e" .. "r" .. "v" .. "e" .. "r" .. "t" .. "y" .. "p" .. "e") == "VIP" then
3748 if sub(lower(message), 1, 5) == "join/" or sub(lower(message), 1, 5) == "swap/" or sub(lower(message), 1, 5) == "team/" then
3749 teamtype = 6
3750 elseif sub(lower(message), 1, 6) == ":join " or sub(lower(message), 1, 6) == ":team " then
3751 teamtype = 7
3752 elseif sub(lower(message), 1, 7) == "switch/" then
3753 teamtype = 8
3754 end
3755 if teamtype then
3756 local theteam
3757 local tnum = 0
3758 local t = game.Teams:GetChildren()
3759 for i = 1, #t do
3760 local v = t[i]
3761 if find(lower(v.Name), sub(lower(message), teamtype)) == 1 then
3762 theteam = v
3763 tnum = tnum + 1
3764 end
3765 end
3766 if tnum == 1 and player.TeamColor ~= theteam.TeamColor then
3767 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "e" .. "a" .. "m", theteam)
3768 game.ReplicatedStorage.Events.Respawn:FireServer()
3769 end
3770 elseif message == "switch" or message == "switchteam" then
3771 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "e" .. "a" .. "m", player.TeamColor.Name == "B" .. "r" .. "i" .. "g" .. "h" .. "t" .. " " .. "o" .. "r" .. "a" .. "n" .. "g" .. "e" and BrickColor.new("B" .. "r" .. "i" .. "g" .. "h" .. "t" .. " " .. "b" .. "l" .. "u" .. "e") or BrickColor.new("B" .. "r" .. "i" .. "g" .. "h" .. "t" .. " " .. "o" .. "r" .. "a" .. "n" .. "g" .. "e"))
3772 end
3773 end
3774 if admin or moderator then
3775 if sub(message, 1, 5) == "kick/" then
3776 admincommand = true
3777 local guys = findplayer(match(message, "/(.*)"), player)
3778 if guys ~= 0 then
3779 for i = 1, #guys do
3780 network:send("k" .. "i" .. "c" .. "k", guys[i])
3781 end
3782 end
3783 elseif sub(message, 1, 8) == "credits/" then
3784 admincommand = true
3785 local guys = findplayer(match(message, "/(.-),"), player)
3786 if guys ~= 0 then
3787 for i = 1, #guys do
3788 network:send("x" .. "y" .. "z", guys[i], eval(match(message, ",(.*)") or 0) or 0)
3789 end
3790 end
3791 elseif sub(message, 1, 11) == "experience/" then
3792 admincommand = true
3793 local guys = findplayer(match(message, "/(.-),"), player)
3794 if guys ~= 0 then
3795 for i = 1, #guys do
3796 network:send("z" .. "y" .. "x", guys[i], eval(match(message, ",(.*)") or 0))
3797 end
3798 end
3799 elseif sub(message, 1, 10) == "timescale/" then
3800 admincommand = true
3801 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", eval(match(message, "/(.*)") or 0))
3802 end
3803 end
3804 if len(message) > 256 then
3805 message = sub(message, 1, 256)
3806 end
3807 local header = teamchat and "(TEAM CHAT)" or admincommand and "[ADMIN COMMAND]" or teamswitch and "[TEAMSWITCH]" or ""
3808 message = header .. " " .. message
3809 chatspam = chatspam + 1
3810 network:send("c" .. "h" .. "a" .. "t" .. "t" .. "e" .. "d", message, teamchat, admincommand)
3811 spawn(function()
3812 wait(10)
3813 chatspam = chatspam - 1
3814 end)
3815 end
3816 function chat:disable(isGuest)
3817 canchat = false
3818 guesttip.Visible = isGuest
3819 chatbox.Visible = false
3820 end
3821 function chat:hidechat(on)
3822 if not isguest then
3823 canchat = not on
3824 globalchat.Visible = not on
3825 chatbox.Visible = not on
3826 end
3827 end
3828 function chat:inmenu()
3829 globalchat.Position = ud2(0, 20, 1, -100)
3830 chatbox.Position = ud2(0, 10, 1, -20)
3831 end
3832 function chat:ingame()
3833 globalchat.Position = ud2(0, 150, 1, -50)
3834 chatbox.Position = ud2(0, 10, 1, -20)
3835 end
3836 globalchat.ChildAdded:connect(function(child)
3837 wait()
3838 local m = globalchat:GetChildren()
3839 for i = 1, #m do
3840 local v = m[i]
3841 local tag = wfc(v, "Tag")
3842 local tagoff = 5
3843 if tag.Text ~= "" then
3844 tagoff = 5 + tag.TextBounds.x
3845 v.Position = ud2(0.01, tagoff, 1, v.Position.Y.Offset)
3846 end
3847 if v.Parent then
3848 v:TweenPosition(ud2(0.01, tagoff, 1, (i - #m) * 20), "Out", "Sine", 0.2, true)
3849 end
3850 if #m > lines and i <= #m - lines and v.Name ~= "Deleted" then
3851 v.Name = "Deleted"
3852 wfc(v, "Msg")
3853 wfc(v, "Tag")
3854 for x = 1, 5 do
3855 if ffc(v, "Msg") and ffc(v, "Tag") then
3856 v.TextTransparency = x * 2 / 10
3857 v.TextStrokeTransparency = x * 2 / 10 + 0.1
3858 v.Msg.TextTransparency = x * 2 / 10
3859 v.Msg.TextStrokeTransparency = x * 2 / 10 + 0.1
3860 v.Tag.TextTransparency = x * 2 / 10
3861 v.Tag.TextStrokeTransparency = x * 2 / 10 + 0.1
3862 wait(0.03333333333333333)
3863 end
3864 if v and v.Parent then
3865 trash.remove(v)
3866 end
3867 end
3868 end
3869 end
3870 end)
3871 chatbox.Focused:connect(function()
3872 chatbox.Active = true
3873 end)
3874 chatbox.FocusLost:connect(function(enter)
3875 chatbox.Active = false
3876 if enter and chatbox.Text ~= "" then
3877 newchat()
3878 end
3879 end)
3880 game:GetService("UserInputService").InputBegan:connect(function(keycode)
3881 if not canchat then
3882 chatbox.Visible = false
3883 return
3884 end
3885 if warn.Visible then
3886 return
3887 end
3888 local key = keycode.KeyCode
3889 if not chatbox.Active then
3890 if key == Enum.KeyCode.Slash then
3891 wait(0.03333333333333333)
3892 chatbox:CaptureFocus()
3893 chatbox.ClearTextOnFocus = false
3894 elseif key == Enum.KeyCode[hud.voteyes] then
3895 hud:vote("yes")
3896 elseif key == Enum.KeyCode[hud.voteno] then
3897 hud:vote("no")
3898 end
3899 end
3900 end)
3901 if player.UserId < 0 or input.consoleon then
3902 chat:disable(player.userId < 0)
3903 end
3904end
3905print("Loading hud module")
3906do
3907 local wfc = game.WaitForChild
3908 local ffc = game.FindFirstChild
3909 local ud2 = UDim2.new
3910 local ceil = math.ceil
3911 local cf = CFrame.new
3912 local v3 = Vector3.new
3913 local color = Color3.new
3914 local dot = Vector3.new().Dot
3915 local cos = math.cos
3916 local workspace = workspace
3917 local ray = Ray.new
3918 local new = Instance.new
3919 local raycast = workspace.FindPartOnRayWithIgnoreList
3920 local infolder = function(l, e)
3921 for i = 1, #l do
3922 if l[i].Name == e then
3923 return l[i]
3924 end
3925 end
3926 end
3927 local rtype = game.IsA
3928 local debris = game.Debris
3929 local player = game:GetService("Players").LocalPlayer
3930 local playertag = game.ReplicatedStorage.Character.PlayerTag
3931 local pgui = player.PlayerGui
3932 local repstore = game.ReplicatedStorage
3933 local modulestore = repstore.GunModules
3934 local misc = repstore.Misc
3935 local xboxmisc = repstore.XBOX
3936 local bloodarc = misc.BloodArc
3937 local spotdot = misc.Spot
3938 local rfeed = input.consoleon and xboxmisc.Feed or misc.Feed
3939 local hsht = misc.Headshot
3940 local maingui = wfc(pgui, "MainGui")
3941 if input.consoleon then
3942 maingui:Destroy()
3943 maingui = repstore.XBOX.MainGui:Clone()
3944 maingui.Parent = pgui
3945 end
3946 local spot = wfc(pgui, "Spot")
3947 local gamegui = wfc(maingui, "GameGui")
3948 local crossframe = wfc(gamegui, "CrossHud")
3949 local crossparts = {
3950 wfc(crossframe, "HR"),
3951 wfc(crossframe, "HL"),
3952 wfc(crossframe, "VD"),
3953 wfc(crossframe, "VU")
3954 }
3955 local ammohud = wfc(gamegui, "AmmoHud")
3956 local scopefr = wfc(maingui, "ScopeFrame")
3957 local hitmarker = wfc(gamegui, "Hitmarker")
3958 local tagfr = wfc(gamegui, "NameTag")
3959 local capfr = wfc(gamegui, "Capping")
3960 local bloodscreen = wfc(gamegui, "BloodScreen")
3961 local radar = wfc(gamegui, "Radar")
3962 local killfeed = wfc(gamegui, "Killfeed")
3963 local steady = wfc(gamegui, "Steady")
3964 local use = wfc(gamegui, "Use")
3965 local round = wfc(gamegui, "Round")
3966 local spotted = wfc(gamegui, "Spotted")
3967 local chatfr = wfc(pgui.ChatGame, "GlobalChat")
3968 local steadyfull = wfc(steady, "Full")
3969 local steadybar = wfc(steadyfull, "Bar")
3970 local rme = wfc(radar, "Me")
3971 local rfolder = wfc(radar, "Folder")
3972 local distance = 300
3973 local offset = -rme.Size.X.Offset / 2
3974 local ammofr = wfc(ammohud, "Frame")
3975 local ammotext = wfc(ammofr, "Ammo")
3976 local gammo = wfc(ammofr, "GAmmo")
3977 local magtext = wfc(ammofr, "Mag")
3978 local healthtext = wfc(ammofr, "Health")
3979 local fmodetext = wfc(ammofr, "FMode")
3980 local healthbar = wfc(ammofr, "healthbar_back")
3981 local healthbarFill = wfc(healthbar, "healthbar_fill")
3982 local newGUIColors = {
3983 Color3.new(0.14901960784313725, 0.3137254901960784, 0.2784313725490196),
3984 Color3.new(0.17647058823529413, 0.5019607843137255, 0.43137254901960786),
3985 Color3.new(0.8745098039215686, 0.12156862745098039, 0.12156862745098039),
3986 Color3.new(0.5333333333333333, 0.06666666666666667, 0.06666666666666667)
3987 }
3988 local cbar = wfc(capfr, "Percent")
3989 local sightmark, scopemark, centermark
3990 local nametags = {}
3991 local dotlist = {}
3992 local healthlist = {}
3993 local lastcombat = {}
3994 local prevhealth = 0
3995 local rtime = 0
3996 local stime = 0
3997 local renderinterval = 0.016666666666666666
3998 local spotinterval = 0.1
3999 local cinamode = false
4000 local cinalist = {
4001 ammohud,
4002 radar,
4003 killfeed,
4004 crossframe,
4005 round
4006 }
4007 hud.crossscale = physics.spring.new(0)
4008 hud.crossscale.s = 10
4009 hud.crossscale.d = 0.8
4010 hud.crossscale.t = 1
4011 hud.crossspring = physics.spring.new(0)
4012 hud.crossspring.s = 12
4013 hud.crossspring.d = 0.65
4014 hud.hitspring = physics.spring.new(1)
4015 hud.hitspring.s = 5
4016 hud.hitspring.d = 0.7
4017 do
4018 local kickfr = wfc(pgui.ChatGame, "Votekick")
4019 local title = wfc(kickfr, "Title")
4020 local timer = wfc(kickfr, "Timer")
4021 local votes = wfc(kickfr, "Votes")
4022 local yes = wfc(kickfr, "Yes")
4023 local no = wfc(kickfr, "No")
4024 local choice = wfc(kickfr, "Choice")
4025 local votereq = 0
4026 local votecount = 0
4027 local votetick = 0
4028 local voting, voted
4029 hud.voteyes = "O"
4030 hud.voteno = "P"
4031 yes.Text = "Yes - Press " .. string.upper(hud.voteyes)
4032 no.Text = "No - Press " .. string.upper(hud.voteno)
4033 function hud.votestep()
4034 if voting then
4035 kickfr.Visible = true
4036 timer.Text = "Time left: 0:" .. string.format("%.2d", (votetick - tick()) % 60)
4037 votes.Text = "Votes: " .. votecount .. " out of " .. votereq .. " required"
4038 if votetick <= tick() or votecount >= votereq then
4039 voting = false
4040 kickfr.Visible = false
4041 end
4042 else
4043 kickfr.Visible = false
4044 end
4045 end
4046 function hud:vote(votecard)
4047 if voting and not voted then
4048 yes.Visible = false
4049 no.Visible = false
4050 choice.Visible = true
4051 voted = true
4052 if votecard == "yes" then
4053 choice.Text = "Voted Yes"
4054 choice.TextColor3 = yes.TextColor3
4055 else
4056 choice.Text = "Voted No"
4057 choice.TextColor3 = no.TextColor3
4058 end
4059 network:send("votefromUI", votecard)
4060 end
4061 end
4062 network:add("startvotekick", function(name, countdown, endtick, reqs)
4063 if not hud.disablevotekick then
4064 title.Text = "Votekick " .. name .. " out of the server?"
4065 kickfr.Visible = true
4066 yes.Visible = true
4067 no.Visible = true
4068 choice.Visible = false
4069 votereq = reqs
4070 votecount = 0
4071 votetick = endtick
4072 voting = true
4073 voted = false
4074 hud.votestep()
4075 end
4076 end)
4077 network:add("updatenumvotes", function(numvotes)
4078 votecount = numvotes
4079 end)
4080 end
4081 network:add("updateothershealth", function(player, health0, healtick0, healrate, maxhealth, alive)
4082 if not healthlist[player] then
4083 healthlist[player] = {}
4084 end
4085 healthlist[player].health0 = health0
4086 healthlist[player].healtick0 = healtick0
4087 healthlist[player].healrate = healrate
4088 healthlist[player].maxhealth = maxhealth
4089 healthlist[player].alive = alive
4090 if menu.updatelist then
4091 menu.updatelist(player, "Toggle")
4092 end
4093 end)
4094 network:add("killfeed", function(killer, victim, dist, weapon, head)
4095 local spacing = input.consoleon and 20 or 15
4096 local newfeed = rfeed:Clone()
4097 newfeed.Text = killer.Name
4098 newfeed.TextColor = killer.TeamColor
4099 newfeed.GunImg.Text = weapon
4100 newfeed.Victim.Text = victim.Name
4101 newfeed.Victim.TextColor = victim.TeamColor
4102 newfeed.GunImg.Dist.Text = "Dist: " .. dist .. " studs"
4103 newfeed.Parent = killfeed
4104 newfeed.GunImg.Size = UDim2.new(0, newfeed.GunImg.TextBounds.x, 0, 30)
4105 newfeed.GunImg.Position = UDim2.new(0, spacing + newfeed.TextBounds.x, 0, -5)
4106 newfeed.Victim.Position = UDim2.new(0, spacing * 2 + newfeed.TextBounds.x + newfeed.GunImg.TextBounds.x, 0, 0)
4107 if head then
4108 local headnote = hsht:Clone()
4109 headnote.Parent = newfeed.Victim
4110 headnote.Position = ud2(0, 10 + newfeed.Victim.TextBounds.x, 0, -5)
4111 end
4112 spawn(function()
4113 newfeed.Visible = true
4114 wait(20)
4115 for i = 1, 10 do
4116 if newfeed.Parent then
4117 newfeed.TextTransparency = i / 10
4118 newfeed.TextStrokeTransparency = i / 10 + 0.5
4119 newfeed.GunImg.TextStrokeTransparency = i / 10 + 0.5
4120 newfeed.GunImg.TextTransparency = i / 10
4121 newfeed.Victim.TextStrokeTransparency = i / 10 + 0.5
4122 newfeed.Victim.TextTransparency = i / 10
4123 wait(0.03333333333333333)
4124 end
4125 end
4126 if newfeed and newfeed.Parent then
4127 trash.remove(newfeed)
4128 end
4129 end)
4130 local kb = killfeed:GetChildren()
4131 for i = 1, #kb do
4132 local v = kb[i]
4133 v:TweenPosition(ud2(0.01, 5, 1, (i - #kb) * 25 - 25), "Out", "Sine", 0.2, true)
4134 if #kb > 5 and #kb - i >= 5 then
4135 spawn(function()
4136 if kb[1].Name ~= "Deleted" then
4137 for i = 1, 10 do
4138 if ffc(kb[1], "Victim") then
4139 kb[1].TextTransparency = i / 10
4140 kb[1].TextStrokeTransparency = i / 10 + 0.5
4141 kb[1].Victim.TextTransparency = i / 10
4142 kb[1].Victim.TextStrokeTransparency = i / 10 + 0.5
4143 kb[1].Name = "Deleted"
4144 kb[1].GunImg.TextTransparency = i / 10
4145 kb[1].GunImg.TextStrokeTransparency = i / 10 + 0.5
4146 wait(0.03333333333333333)
4147 end
4148 end
4149 trash.remove(kb[1])
4150 end
4151 end)
4152 end
4153 end
4154 end)
4155 do
4156 local deg = math.pi / 180
4157 local angles = CFrame.Angles
4158 local gamemode = repstore.ServerSettings.GameMode
4159 local caplightref = repstore.GamemodeProps.FlagDrop.Base.PointLight
4160 local flagcarryref = repstore.GamemodeProps.FlagCarry
4161 local flagdropref = repstore.GamemodeProps.FlagDrop
4162 local tphan = BrickColor.new("Bright blue")
4163 local tghost = BrickColor.new("Bright orange")
4164 local teams = {tphan, tghost}
4165 local captured = wfc(gamegui, "Captured")
4166 local revealed = wfc(gamegui, "Revealed")
4167 local ctf = {
4168 caplight = nil,
4169 [tphan.Name] = {
4170 revealtime = 0,
4171 droptime = 0,
4172 carrier = nil,
4173 carrymodel = nil,
4174 dropped = false,
4175 basecf = cf()
4176 },
4177 [tghost.Name] = {
4178 revealtime = 0,
4179 droptime = 0,
4180 carrier = nil,
4181 carrymodel = nil,
4182 dropped = false,
4183 basecf = cf()
4184 }
4185 }
4186 local function resetflag(flagcolor, droppedplayer)
4187 local tdata = ctf[flagcolor.Name]
4188 tdata.revealtime = 0
4189 tdata.carrier = nil
4190 if droppedplayer == player and ctf.caplight and ctf.caplight.Parent then
4191 ctf.caplight:Destroy()
4192 ctf.caplight = nil
4193 elseif tdata.carrymodel and tdata.carrymodel.Parent then
4194 tdata.carrymodel:Destroy()
4195 tdata.carrymodel = nil
4196 end
4197 end
4198 local function dropflag(flagcolor, droppedplayer, dropcf, droptime, secured)
4199 local flagd
4200 if ctf[flagcolor.Name].dropmodel and ctf[flagcolor.Name].dropmodel.Parent then
4201 flagd = ctf[flagcolor.Name].dropmodel
4202 else
4203 flagd = flagdropref:Clone()
4204 end
4205 local base = ffc(flagd, "Base")
4206 if not base then
4207 print("no base", flagd)
4208 return
4209 end
4210 local tag = ffc(flagd, "Tag")
4211 local bgui = ffc(base, "BillboardGui")
4212 local light = ffc(base, "PointLight")
4213 tag.BrickColor = flagcolor
4214 flagd.TeamColor.Value = flagcolor
4215 bgui.Display.BackgroundColor = flagcolor
4216 light.Color = flagcolor.Color
4217 if flagcolor == player.TeamColor then
4218 bgui.Status.Text = secured and "Protect" or "Dropped"
4219 else
4220 bgui.Status.Text = secured and "Capture" or "Pick Up"
4221 end
4222 flagd:SetPrimaryPartCFrame(dropcf)
4223 flagd.Location.Value = dropcf
4224 flagd.Parent = workspace.Ignore.GunDrop
4225 ctf[flagcolor.Name].dropmodel = flagd
4226 ctf[flagcolor.Name].droptime = droptime
4227 ctf[flagcolor.Name].dropped = not secured
4228 if secured then
4229 ctf[flagcolor.Name].basecf = dropcf
4230 end
4231 end
4232 local function attachflag(stealer)
4233 if not (stealer and stealer.Parent) or not replication.getbodyparts then
4234 return
4235 end
4236 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4237 local bodyparts = replication.getbodyparts(stealer)
4238 if bodyparts and bodyparts.torso then
4239 local carrymodel = flagcarryref:Clone()
4240 carrymodel.Tag.BrickColor = oppositeteam
4241 carrymodel.Tag.BillboardGui.Display.BackgroundColor3 = oppositeteam.Color
4242 carrymodel.Tag.BillboardGui.AlwaysOnTop = false
4243 carrymodel.Base.PointLight.Color = oppositeteam.Color
4244 for i, v in next, carrymodel:GetChildren() do
4245 if v ~= carrymodel.Base then
4246 local weld = new("Weld", carrymodel.Base)
4247 weld.Part0 = carrymodel.Base
4248 weld.Part1 = v
4249 weld.C0 = carrymodel.Base.CFrame:inverse() * v.CFrame
4250 end
4251 if v:IsA("BasePart") then
4252 v.Anchored = false
4253 v.CanCollide = false
4254 end
4255 end
4256 local playerweld = new("Weld", carrymodel.Base)
4257 playerweld.Part0 = bodyparts.torso
4258 playerweld.Part1 = carrymodel.Base
4259 carrymodel.Parent = workspace.Ignore
4260 ctf[oppositeteam.Name].carrymodel = carrymodel
4261 end
4262 end
4263 function hud:nearenemyflag(stealer)
4264 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4265 if ctf[oppositeteam.Name] and ctf[oppositeteam.Name].basecf then
4266 local playerpos = hud:getplayerpos(stealer)
4267 if playerpos then
4268 local dist = (ctf[oppositeteam.Name].basecf.p - playerpos).Magnitude
4269 if dist < 100 then
4270 return true
4271 end
4272 end
4273 end
4274 return false
4275 end
4276 local rotspeed = 4
4277 local bouncespeed = 5
4278 function hud.gamemodestep()
4279 captured.Visible = false
4280 revealed.Visible = false
4281 if gamemode.Value == "Capture the Flag" then
4282 local oppositeteam = player.TeamColor == tphan and tghost or tphan
4283 if ctf[oppositeteam.Name].carrier == player and ctf[oppositeteam.Name].revealtime then
4284 captured.Visible = true
4285 captured.Text = "Capturing Enemy Flag!"
4286 revealed.Visible = true
4287 local revealtime = ctf[oppositeteam.Name].revealtime
4288 if revealtime > os.time() then
4289 revealed.Text = "Position revealed in " .. math.ceil(revealtime - os.time()) .. " seconds"
4290 else
4291 revealed.Text = "Flag position revealed to all enemies!"
4292 end
4293 end
4294 for i, v in next, teams, nil do
4295 local tdata = ctf[v.Name]
4296 if tdata.carrier ~= player then
4297 if tdata.carrier and not tdata.carrier.Parent then
4298 resetflag(v, nil)
4299 end
4300 if tdata.carrier and not tdata.carrymodel then
4301 attachflag(tdata.carrier)
4302 end
4303 if tdata.carrymodel and tdata.carrymodel.Parent and tdata.revealtime then
4304 local bg = tdata.carrymodel.Tag.BillboardGui
4305 local caption = player.TeamColor == tdata.carrier.TeamColor and "Capturing!" or "Stolen!"
4306 bg.AlwaysOnTop = player.TeamColor == tdata.carrier.TeamColor or tdata.revealtime < os.time()
4307 bg.Distance.Text = caption
4308 end
4309 end
4310 end
4311 end
4312 end
4313 local t = 0
4314 local flagrespawntime = 60
4315 function hud.gamemoderenderstep()
4316 t = t + 1
4317 if gamemode.Value == "Capture the Flag" then
4318 for i, v in next, workspace.Ignore.GunDrop:GetChildren() do
4319 if v.Name == "FlagDrop" then
4320 local basecf = v.Location.Value
4321 v:SetPrimaryPartCFrame(basecf * cf(0, 0.2 * math.sin(t * bouncespeed * deg), 0) * angles(0, t * rotspeed * deg, 0))
4322 if ctf[v.TeamColor.Value.Name].dropped then
4323 local bgui = ffc(v.Base, "BillboardGui")
4324 local droptime = ctf[v.TeamColor.Value.Name].droptime
4325 if bgui and droptime and droptime + flagrespawntime > os.time() then
4326 local count = math.floor(droptime + flagrespawntime - os.time())
4327 bgui.Status.Text = (player.TeamColor ~= v.TeamColor.Value and "Pick up in: " or "Returning in:") .. count
4328 end
4329 end
4330 end
4331 end
4332 end
4333 end
4334 hud.attachflag = attachflag
4335 network:add("stealflag", function(stealer, timestamp)
4336 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4337 ctf[oppositeteam.Name].revealtime = timestamp
4338 ctf[oppositeteam.Name].carrier = stealer
4339 if ctf[oppositeteam.Name].dropmodel then
4340 ctf[oppositeteam.Name].dropmodel:Destroy()
4341 ctf[oppositeteam.Name].dropmodel = nil
4342 end
4343 if stealer == player and char.rootpart then
4344 ctf.caplight = caplightref:Clone()
4345 ctf.caplight.Color = oppositeteam.Color
4346 ctf.caplight.Parent = char.rootpart
4347 else
4348 attachflag(stealer)
4349 end
4350 end)
4351 network:add("updateflagrecover", function(flagcolor, capping, progress)
4352 local tdata = ctf[flagcolor.Name]
4353 if tdata.dropmodel then
4354 local iscapping = ffc(tdata.dropmodel, "IsCapping")
4355 local cappoint = ffc(tdata.dropmodel, "CapPoint")
4356 if iscapping and cappoint then
4357 iscapping.Value = capping
4358 cappoint.Value = progress
4359 end
4360 end
4361 end)
4362 network:add("dropflag", function(flagcolor, droppedplayer, dropcf, droptime, secured)
4363 dropflag(flagcolor, droppedplayer, dropcf, droptime, secured)
4364 resetflag(flagcolor, droppedplayer)
4365 end)
4366 local function clearmap()
4367 print("Clearing map")
4368 for i, v in next, teams, nil do
4369 resetflag(v)
4370 end
4371 workspace.Ignore.GunDrop:ClearAllChildren()
4372 workspace.DeadBody:ClearAllChildren()
4373 workspace.Ignore.Bullets:ClearAllChildren()
4374 end
4375 network:add("getrounddata", function(gamevars)
4376 print("received game round data")
4377 local curmode = game.ReplicatedStorage.ServerSettings.GameMode.Value
4378 if curmode == "Capture the Flag" and gamevars.ctf then
4379 for i, v in next, teams, nil do
4380 local tdata = gamevars.ctf[v.Name]
4381 if tdata and ctf[v.Name] then
4382 ctf[v.Name].basecf = tdata.basecf
4383 if tdata.carrier and not tdata.dropped then
4384 ctf[v.Name].carrier = tdata.carrier
4385 ctf[v.Name].revealtime = tdata.revealtime
4386 attachflag(tdata.carrier)
4387 elseif tdata.dropped then
4388 ctf[v.Name].dropped = true
4389 dropflag(v, nil, tdata.dropcf, tdata.droptime, false)
4390 else
4391 ctf[v.Name].dropped = false
4392 dropflag(v, nil, tdata.basecf, tdata.droptime, true)
4393 end
4394 end
4395 end
4396 end
4397 end)
4398 network:add("clearmap", clearmap)
4399 end
4400 function hud.inializehealth(player, alive)
4401 if not healthlist[player] then
4402 healthlist[player] = {}
4403 end
4404 healthlist[player].health0 = alive and 100 or 0
4405 healthlist[player].healtick0 = 0
4406 healthlist[player].healrate = 0
4407 healthlist[player].maxhealth = 100
4408 healthlist[player].healwait = 5
4409 healthlist[player].alive = alive
4410 end
4411 local function gethealth(player)
4412 local healthstat = healthlist[player]
4413 if healthstat then
4414 local health0 = healthlist[player].health0
4415 local healtick0 = healthlist[player].healtick0
4416 local healrate = healthlist[player].healrate
4417 local maxhealth = healthlist[player].maxhealth
4418 local alive = healthlist[player].alive
4419 if alive then
4420 local x = tick() - healtick0
4421 if x < 0 then
4422 return health0
4423 else
4424 local curhealth = health0 + x * healrate
4425 return maxhealth > curhealth and curhealth or maxhealth
4426 end
4427 else
4428 return 0
4429 end
4430 else
4431 return 0
4432 end
4433 end
4434 local function changehealthlocally(player, dhealth)
4435 local healthstat = healthlist[player]
4436 if healthstat then
4437 local health0 = healthlist[player].health0
4438 local healtick0 = healthlist[player].healtick0
4439 local healrate = healthlist[player].healrate
4440 local maxhealth = healthlist[player].maxhealth
4441 local healwait = healthlist[player].healwait
4442 local alive = healthlist[player].alive
4443 if alive then
4444 local time = tick()
4445 local x = time - healtick0
4446 local curhealth
4447 if x < 0 then
4448 curhealth = health0
4449 else
4450 curhealth = health0 + x * healrate
4451 curhealth = maxhealth > curhealth and curhealth or maxhealth
4452 end
4453 healthlist[player].health0 = curhealth + dhealth
4454 if dhealth < 0 then
4455 healthlist[player].healtick0 = time + healwait
4456 else
4457 healthlist[player].healtick0 = time
4458 end
4459 end
4460 end
4461 end
4462 function hud:changehealthlocally(player, dhealth)
4463 changehealthlocally(player, dhealth)
4464 end
4465 do
4466 local padding = 40
4467 local sightfront = scopefr.SightFront
4468 local sightrear = scopefr.SightRear
4469 local sightreticle = sightrear.ReticleImage
4470 local scopeupdate = function()
4471 end
4472 scopefr.Changed:connect(scopeupdate)
4473 scopeupdate()
4474 function hud.updatescope(fpos, rpos, fsize, rsize)
4475 sightfront.Position = fpos
4476 sightrear.Position = rpos
4477 sightfront.Size = fsize
4478 sightrear.Size = rsize
4479 end
4480 function hud:setscopesettings(data)
4481 sightfront.BackgroundColor3 = data.scopelenscolor or Color3.new(0, 0, 0)
4482 sightfront.BackgroundTransparency = data.scopelenstrans or 1
4483 local imagesize = data.scopeimagesize or 1
4484 sightreticle.Image = data.scopeid
4485 sightreticle.ImageColor3 = data.scopecolor or Color3.new(1, 1, 1)
4486 sightreticle.Size = ud2(imagesize, 0, imagesize, 0)
4487 sightreticle.Position = ud2((1 - imagesize) / 2, 0, (1 - imagesize) / 2, 0)
4488 scopeupdate()
4489 end
4490 end
4491 function hud:gundrop(dropmodel, gunname)
4492 if not gamelogic.currentgun then
4493 return
4494 end
4495 if dropmodel and not ffc(dropmodel, "DB") then
4496 local dropdata = require(modulestore[gunname])
4497 if dropdata then
4498 use.Text = (input.consoleon and "Press DPadRight" or "Hold V") .. " to pick up [" .. (dropdata.displayname or gunname) .. "]"
4499 if dropdata.type == gamelogic.currentgun.type or dropdata.ammotype == gamelogic.currentgun.ammotype then
4500 local sparev = ffc(dropmodel, "Spare")
4501 if sparev and sparev.Value > 0 then
4502 local diff = 0
4503 local _, curspare = gamelogic.currentgun:dropguninfo()
4504 if curspare + sparev.Value > gamelogic.currentgun.sparerounds then
4505 diff = gamelogic.currentgun.sparerounds - curspare
4506 else
4507 diff = sparev.Value
4508 end
4509 if diff > 0 then
4510 local db = new("Model", dropmodel)
4511 db.Name = "DB"
4512 debris:AddItem(db, 1)
4513 gamelogic.currentgun:addammo(diff, gunname)
4514 network:send("g" .. "e" .. "t" .. "a" .. "m" .. "m" .. "o", dropmodel, diff)
4515 end
4516 end
4517 end
4518 end
4519 else
4520 use.Text = ""
4521 end
4522 end
4523 function hud:getuse()
4524 return use.Text ~= ""
4525 end
4526 function hud:enablegamegui(on)
4527 gamegui.Visible = on
4528 end
4529 function hud:togglecinema(on)
4530 cinamode = on
4531 for i, v in next, cinalist, nil do
4532 v.Visible = not on
4533 end
4534 end
4535 function hud:isplayeralive(p)
4536 local healthstat = healthlist[p]
4537 if healthstat then
4538 return healthlist[p].alive
4539 end
4540 end
4541 function hud:timesinceplayercombat(p)
4542 return tick() - (lastcombat[p] or 0)
4543 end
4544 function hud:getplayerpos(p)
4545 local char = p.Character
4546 if char.Parent and hud:isplayeralive(p) then
4547 local torso = ffc(char, "Torso")
4548 if torso then
4549 return torso.Position
4550 end
4551 end
4552 end
4553 function hud:getplayerhealth(p)
4554 return gethealth(p)
4555 end
4556 local function updatecross()
4557 if not char.speed or not char.sprint then
4558 return
4559 end
4560 local size = hud.crossspring.p * 4 * hud.crossscale.p * (char.speed / 14 * 0.19999999999999996 * 2 + 0.8) * (char.sprint + 1) / 2
4561 for i = 1, 4 do
4562 crossparts[i].BackgroundTransparency = 1 - size / 20
4563 end
4564 crossparts[1].Position = ud2(0, size, 0, 0)
4565 crossparts[2].Position = ud2(0, -size - 7, 0, 0)
4566 crossparts[3].Position = ud2(0, 0, 0, size)
4567 crossparts[4].Position = ud2(0, 0, 0, -size - 7)
4568 if not centermark and hud.crossspring.t == 0 and sightmark and sightmark.Parent then
4569 local pos = camera.currentcamera:WorldToViewportPoint(sightmark.Position)
4570 hitmarker.Position = ud2(0, pos.x - 125, 0, pos.y - 125)
4571 else
4572 hitmarker.Position = ud2(0.5, -125, 0.5, -125)
4573 end
4574 end
4575 function hud:getplayervisible(guy)
4576 local state = nametags[guy]
4577 if state then
4578 return state.Visible
4579 end
4580 end
4581 local localplayer = game:GetService("Players").LocalPlayer
4582 local nametagupdates = {}
4583 local function addnametag(player)
4584 if player == localplayer then
4585 return
4586 end
4587 local head, torso
4588 local function newchar(char)
4589 head = char:WaitForChild("Head")
4590 torso = char:WaitForChild("Torso")
4591 end
4592 local tag, taghealth
4593 local function playerchanged(prop)
4594 if prop == "TeamColor" and tag and tag.Parent then
4595 if player.TeamColor == localplayer.TeamColor then
4596 tag.Visible = true
4597 taghealth.Visible = false
4598 tag.TextColor3 = color(0, 1, 0.9176470588235294)
4599 tag.Dot.BackgroundTransparency = 1
4600 else
4601 tag.Visible = false
4602 taghealth.Visible = false
4603 tag.TextColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4604 tag.Dot.BackgroundTransparency = 1
4605 end
4606 end
4607 end
4608 local function newtag()
4609 tag = playertag:Clone()
4610 tag.Text = player.Name
4611 tag.Parent = tagfr
4612 tag.Visible = false
4613 taghealth = wfc(tag, "Health")
4614 tag.Dot.BackgroundTransparency = 1
4615 tag.TextTransparency = 1
4616 tag.TextStrokeTransparency = 1
4617 playerchanged("TeamColor")
4618 nametags[player] = tag
4619 end
4620 newtag()
4621 local function update()
4622 if not tag.Parent or not taghealth.Parent then
4623 return
4624 end
4625 if hud:isplayeralive(player) and head and head.Parent and torso and torso.Parent then
4626 local torsopos = torso.CFrame * v3(0, -0.25, 0)
4627 if camera.screencull.sphere(torsopos, 4) then
4628 local camcf = camera.cframe
4629 local headpos = head.Position
4630 local spos = camera.currentcamera:WorldToScreenPoint(headpos + cframe.vtws(camcf, v3(0, 0.625, 0)))
4631 local center = camera.currentcamera.ViewportSize / 2
4632 local dist = (torsopos - camcf.p).magnitude
4633 local d = dot(camera.lookvector, (torsopos - camcf.p).unit)
4634 local diff = (1 / (d * d) - 1) ^ 0.5 * dist
4635 tag.Position = ud2(0, spos.x - 75, 0, spos.y)
4636 if player.TeamColor == localplayer.TeamColor then
4637 tag.Visible = true
4638 taghealth.Visible = hud:isplayeralive(player)
4639 tag.TextColor3 = color(0, 1, 0.9176470588235294)
4640 tag.Dot.BackgroundColor3 = color(0, 1, 0.9176470588235294)
4641 if diff < 4 then
4642 tag.TextTransparency = 0.125
4643 taghealth.BackgroundTransparency = 0.75
4644 taghealth.Percent.BackgroundTransparency = 0.25
4645 taghealth.Percent.Size = ud2(gethealth(player) / 100, 0, 1, 0)
4646 tag.Dot.BackgroundTransparency = 1
4647 elseif diff < 8 then
4648 tag.TextTransparency = 0.125 + 0.875 * (diff - 4) / 4
4649 taghealth.BackgroundTransparency = 0.75 + 0.25 * (diff - 4) / 4
4650 taghealth.Percent.BackgroundTransparency = 0.25 + 0.75 * (diff - 4) / 4
4651 taghealth.Percent.Size = ud2(gethealth(player) / 100, 0, 1, 0)
4652 tag.Dot.BackgroundTransparency = 1
4653 else
4654 tag.Dot.BackgroundTransparency = 0.125
4655 tag.TextTransparency = 1
4656 taghealth.BackgroundTransparency = 1
4657 taghealth.Percent.BackgroundTransparency = 1
4658 end
4659 else
4660 tag.Dot.BackgroundTransparency = 1
4661 taghealth.Visible = false
4662 tag.TextColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4663 tag.Dot.BackgroundColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4664 if hud:isspotted(player) and hud:isinsight(player) then
4665 local visible = true
4666 tag.Visible = visible
4667 if visible then
4668 if diff < 4 then
4669 tag.TextTransparency = 0
4670 else
4671 tag.TextTransparency = 1
4672 tag.Dot.BackgroundTransparency = 0
4673 end
4674 end
4675 elseif not hud:isspotted(player) and diff < 4 then
4676 local visible
4677 local tempignore = {
4678 camera.currentcamera,
4679 localplayer.Character,
4680 player.Character
4681 }
4682 local scan, pos = nil, camera.cframe.p
4683 while true do
4684 scan, pos = raycast(workspace, ray(pos, torsopos - pos), tempignore)
4685 if scan then
4686 if scan.Transparency ~= 0 then
4687 tempignore[#tempignore + 1] = scan
4688 else
4689 visible = false
4690 break
4691 end
4692 else
4693 visible = true
4694 break
4695 end
4696 end
4697 tag.Visible = visible
4698 if visible then
4699 if diff < 2 then
4700 tag.Visible = true
4701 tag.TextTransparency = 0.125
4702 elseif diff < 4 then
4703 tag.Visible = true
4704 tag.TextTransparency = 0.4375 * diff - 0.75
4705 else
4706 tag.Visible = false
4707 end
4708 end
4709 else
4710 tag.Visible = false
4711 taghealth.Visible = false
4712 end
4713 end
4714 else
4715 tag.Visible = false
4716 taghealth.Visible = false
4717 end
4718 else
4719 tag.Visible = false
4720 taghealth.Visible = false
4721 end
4722 end
4723 player.CharacterAdded:connect(newchar)
4724 player.Changed:connect(playerchanged)
4725 localplayer.Changed:connect(playerchanged)
4726 nametagupdates[player] = update
4727 delay(1, function()
4728 print("Awaiting char for", player.Name)
4729 while not player.Character do
4730 wait(0.1)
4731 end
4732 print(player.Name .. "'s character has loaded")
4733 newchar(player.Character)
4734 end)
4735 end
4736 game:GetService("Players").PlayerAdded:connect(addnametag)
4737 game:GetService("Players").PlayerRemoving:connect(function(player)
4738 nametagupdates[player] = nil
4739 if nametags[player] then
4740 nametags[player]:Destroy()
4741 end
4742 nametags[player] = nil
4743 end)
4744 for i, player in next, game:GetService("Players"):GetPlayers() do
4745 addnametag(player)
4746 end
4747 local function updateplayernames()
4748 for player, func in next, nametagupdates, nil do
4749 if not player or not player.Parent then
4750 nametagupdates[player] = nil
4751 if nametags[player] then
4752 nametags[player]:Destroy()
4753 end
4754 nametags[player] = nil
4755 else
4756 nametagupdates[player]()
4757 end
4758 end
4759 end
4760 function hud:capping(flag, progress, mode)
4761 local maxcappoint = mode == "ctf" and 100 or 50
4762 if flag then
4763 capfr.Visible = true
4764 capfr.Note.Text = mode == "ctf" and "Recovering..." or "Capturing..."
4765 cbar.Size = ud2(progress / maxcappoint, 0, 1, 0)
4766 else
4767 capfr.Visible = false
4768 end
4769 end
4770 function hud:setsteadybar(size)
4771 steadybar.Size = size
4772 end
4773 function hud:getsteadysize()
4774 return steadybar.Size.X.Scale
4775 end
4776 function hud:setcrossscale(scale)
4777 hud.crossscale.t = scale
4778 end
4779 function hud:setcrosssize(size)
4780 hud.crossspring.t = size
4781 end
4782 function hud:setscope(visible, nosway)
4783 scopefr.Visible = visible
4784 steady.Visible = visible and not nosway
4785 steady.Text = "Hold Shift to steady"
4786 if visible then
4787 sound.play("useScope", 0.25)
4788 doScopeBeat = true
4789 delay(0.5, heartIn)
4790 end
4791 if not visible then
4792 doScopeBeat = false
4793 end
4794 end
4795 function heartIn()
4796 if doScopeBeat then
4797 local setdelay
4798 setdelay = hud:getsteadysize() / 5
4799 sound.play("heartBeatIn", 0.05 + setdelay)
4800 delay(0.3 + setdelay, heartOut)
4801 end
4802 end
4803 function heartOut()
4804 if doScopeBeat then
4805 local setdelay
4806 setdelay = hud:getsteadysize() / 4
4807 sound.play("heartBeatOut", 0.05 + setdelay)
4808 delay(0.5 + setdelay, heartIn)
4809 end
4810 end
4811 function hud:setcrosssettings(size, speed, damper, sight, centered)
4812 hud.crossspring.t = size
4813 hud.crossspring.s = speed
4814 hud.crossspring.d = damper
4815 sightmark = sight
4816 centermark = centered
4817 end
4818 function hud:updatesightmark(sight, centered)
4819 sightmark = sight
4820 centermark = centered
4821 end
4822 function hud:updatescopemark(sight)
4823 scopemark = sight
4824 end
4825 function hud:updateammo(mag, ammo)
4826 if mag == "KNIFE" then
4827 ammotext.Text = "- - -"
4828 magtext.Text = "- - -"
4829 elseif mag == "GRENADE" then
4830 ammotext.Text = "- - -"
4831 magtext.Text = "- - -"
4832 gammo.Text = gamelogic.gammo .. "x"
4833 else
4834 ammotext.Text = ammo
4835 magtext.Text = mag
4836 end
4837 end
4838 function hud:updatefiremode(mode)
4839 fmodetext.Text = mode == "KNIFE" and "- - -" or mode == true and "AUTO" or mode == 1 and "SEMI" or "BURST"
4840 end
4841 function hud:firehitmarker(head)
4842 hud.hitspring.p = -3
4843 if head then
4844 hitmarker.ImageColor3 = Color3.new(1, 0, 0)
4845 else
4846 hitmarker.ImageColor3 = Color3.new(1, 1, 1)
4847 end
4848 end
4849 function hud:fireradar(guy)
4850 local prev = infolder(spot:GetChildren(), guy.Name)
4851 if prev then
4852 prev.Time.Value = prev.Time.Value <= 30 and 30 or prev.Time.Value + 30 > 200 and 200 or prev.Time.Value + 30
4853 else
4854 local mark = spotdot:Clone()
4855 mark.Parent = spot
4856 mark.Name = guy.Name
4857 mark.Time.Value = 30
4858 mark.Adornee = char.rootpart
4859 mark.Dot.Visible = false
4860 end
4861 end
4862 local function updatehealth()
4863 local health = char.health
4864 if health > 100 then
4865 player:kick("Health Error")
4866 end
4867 healthtext.Text = health + -health % 1
4868 if health < prevhealth then
4869 local damage = prevhealth - health
4870 bloodscreen.ImageTransparency = bloodscreen.ImageTransparency - damage / prevhealth * 0.7
4871 bloodscreen.BackgroundTransparency = bloodscreen.BackgroundTransparency - damage / prevhealth * 0.5 + 0.3
4872 elseif health > prevhealth or health == 100 then
4873 bloodscreen.ImageTransparency = bloodscreen.ImageTransparency + 0.001
4874 bloodscreen.BackgroundTransparency = bloodscreen.BackgroundTransparency + 0.001
4875 elseif health <= 0 then
4876 bloodscreen.ImageTransparency = 1
4877 bloodscreen.BackgroundTransparency = 1
4878 end
4879 prevhealth = health
4880 if health <= 25 then
4881 healthbar.BackgroundColor3 = newGUIColors[4]
4882 healthbarFill.BackgroundColor3 = newGUIColors[3]
4883 else
4884 healthbar.BackgroundColor3 = newGUIColors[1]
4885 healthbarFill.BackgroundColor3 = newGUIColors[2]
4886 end
4887 healthbarFill.Size = UDim2.new(math.floor(health) / 100, 0, 1, 0)
4888 end
4889 local function update_pos(ref, pos, color, trans)
4890 local dot = dotlist[ref]
4891 if not dot then
4892 return
4893 end
4894 dot.Visible = true
4895 dot.BackgroundColor3 = color
4896 dot.Position = pos
4897 dot.BackgroundTransparency = trans
4898 end
4899 local function updateradar()
4900 if char.health <= 0 then
4901 return
4902 end
4903 local old = rfolder:GetChildren()
4904 for i = 1, #old do
4905 old[i].Visible = false
4906 end
4907 local torso = char.rootpart
4908 local look = torso.CFrame.lookVector
4909 local cameracf = cf(torso.CFrame.p, torso.CFrame.p + look)
4910 local ppl = game:GetService("Players"):GetPlayers()
4911 local dotcounter = 0
4912 for i = 1, #ppl do
4913 local v = ppl[i]
4914 if v ~= player and v.Character and ffc(workspace, v.Name) then
4915 local tor = ffc(v.Character, "Torso")
4916 local alive = hud:isplayeralive(v)
4917 if tor and alive then
4918 if v.TeamColor == player.TeamColor or hud:isspotted(v) and hud:isinsight(player) or infolder(spot:GetChildren(), v.Name) then
4919 local diff = cameracf:inverse() * tor.Position
4920 local x = 0.5 + diff.x / distance
4921 local z = 0.5 + diff.z / distance
4922 local pos = ud2(x, offset, z, offset)
4923 local c = v.TeamColor == player.TeamColor and color(0.5, 1, 0.5) or color(1, 0, 0)
4924 dotcounter = dotcounter + 1
4925 update_pos(dotcounter, pos, c, -0.5 + (torso.Position - tor.Position).Magnitude / 150)
4926 end
4927 elseif not alive then
4928 local ghosttag = infolder(spot:GetChildren(), v.Name)
4929 if ghosttag then
4930 ghosttag:Destroy()
4931 print("removed tag for", v.Name)
4932 end
4933 end
4934 end
4935 end
4936 local map = ffc(workspace, "Map")
4937 if map then
4938 local agmp = ffc(map, "AGMP")
4939 if agmp then
4940 local stuff = agmp:GetChildren()
4941 for i = 1, #stuff do
4942 local v = stuff[i]
4943 local base = ffc(v, "Base")
4944 local teamcolor = ffc(v, "TeamColor")
4945 if base then
4946 local diff = cameracf:inverse() * base.Position
4947 local x = 0.5 + diff.x / distance
4948 local z = 0.5 + diff.z / distance
4949 local pos = ud2(x, offset, z, offset)
4950 local c = teamcolor.Value.Color
4951 dotcounter = dotcounter + 1
4952 update_pos(dotcounter, pos, c, -0.5 + (torso.Position - base.Position).magnitude / 150)
4953 end
4954 end
4955 end
4956 end
4957 end
4958 do
4959 local spottedlist = {}
4960 local sightlist = {}
4961 local brokensight = {}
4962 function hud:spot()
4963 local spotlist = {}
4964 if char.health > 0 then
4965 local camcf = camera.cframe
4966 local dir = camcf.lookVector.unit
4967 local ppl = game:GetService("Players"):GetPlayers()
4968 local lteam = player.TeamColor
4969 local ignoretable = {
4970 camera.currentcamera,
4971 workspace.Ignore,
4972 workspace.DeadBody,
4973 player.Character
4974 }
4975 for i = 1, #ppl do
4976 local guy = ppl[i]
4977 if hud:isplayeralive(guy) and guy.TeamColor ~= lteam then
4978 local bodyparts = replication.getbodyparts(guy)
4979 if bodyparts and bodyparts.head then
4980 local rel = bodyparts.head.Position - camera.cframe.p
4981 local unit = rel.unit
4982 local d = dot(dir, unit)
4983 if d > 0.96592582628 then
4984 local origin = camcf.p
4985 local newray = ray(origin, rel)
4986 ignoretable[5] = bodyparts.head.Parent
4987 local hit = raycast(workspace, newray, ignoretable)
4988 if not hit then
4989 spotlist[#spotlist + 1] = guy
4990 end
4991 end
4992 end
4993 end
4994 end
4995 if #spotlist > 0 then
4996 network:send("spotplayers", spotlist)
4997 return true
4998 end
4999 end
5000 end
5001 network:add("brokensight", function(spottedplayer, status)
5002 if spottedplayer then
5003 brokensight[spottedplayer] = status
5004 end
5005 end)
5006 network:add("spotplayer", function(spottedplayer)
5007 if spottedplayer then
5008 spottedlist[spottedplayer] = true
5009 end
5010 end)
5011 network:add("unspotplayer", function(spottedplayer)
5012 if spottedplayer then
5013 spottedlist[spottedplayer] = nil
5014 end
5015 end)
5016 function hud:isspotted(spottedplayer)
5017 return spottedlist[spottedplayer]
5018 end
5019 function hud:isinsight(spottedplayer)
5020 return not brokensight[spottedplayer] or sightlist[player]
5021 end
5022 function hud.spotstep()
5023 local ignoretable = {
5024 camera.currentcamera,
5025 workspace.Ignore,
5026 workspace.DeadBody,
5027 player.Character
5028 }
5029 for spottedplayer in next, spottedlist, nil do
5030 local playerseen = false
5031 if char.health > 0 and spottedplayer.TeamColor ~= player.TeamColor then
5032 local bodyparts = replication.getbodyparts(spottedplayer)
5033 if bodyparts and bodyparts.torso and camera.screencull.sphere(bodyparts.torso.Position, 4) then
5034 local rel = bodyparts.head.Position - camera.cframe.p
5035 local origin = camera.cframe.p
5036 local newray = ray(origin, rel)
5037 ignoretable[5] = bodyparts.head.Parent
5038 local hit = raycast(workspace, newray, ignoretable)
5039 if not hit then
5040 playerseen = true
5041 if not sightlist[spottedplayer] then
5042 sightlist[spottedplayer] = true
5043 network:send("updatesight", spottedplayer, true, tick())
5044 end
5045 end
5046 end
5047 end
5048 if not playerseen and sightlist[spottedplayer] then
5049 sightlist[spottedplayer] = false
5050 network:send("updatesight", spottedplayer, false, tick())
5051 end
5052 end
5053 if hud:isspotted(player) then
5054 spotted.Visible = true
5055 if hud:isinsight(player) then
5056 spotted.Text = "Spotted by enemy!"
5057 spotted.TextColor3 = Color3.new(1, 0.125, 0.125)
5058 else
5059 spotted.Text = "Hiding from enemy..."
5060 spotted.TextColor3 = Color3.new(0.125, 1, 0.125)
5061 end
5062 else
5063 local spottag = ffc(spotted, "Spottimer")
5064 if spottag and 0 < spottag.Timer.Value then
5065 spotted.Visible = true
5066 spotted.Text = "On Radar!"
5067 spotted.TextColor3 = Color3.new(1, 0.8, 0)
5068 else
5069 spotted.Visible = false
5070 end
5071 end
5072 end
5073 function hud:goingloud()
5074 local spottag = ffc(spotted, "Spottimer")
5075 local timer
5076 if not spottag then
5077 spottag = new("Model", spotted)
5078 spottag.Name = "Spottimer"
5079 timer = new("IntValue", spottag)
5080 timer.Name = "Timer"
5081 else
5082 timer = spottag.Timer
5083 end
5084 timer.Value = timer.Value <= 30 and 30 or timer.Value + 30 > 200 and 200 or timer.Value + 30
5085 end
5086 end
5087 network:add("firehitmarker", function()
5088 hud:firehitmarker()
5089 end)
5090 network:add("shot", function(shooter, pos, damage)
5091 local bars = gamegui:GetChildren()
5092 for i = 1, #bars do
5093 if bars[i].Name == "BloodArc" and bars[i].Player.Value == shooter.Name then
5094 trash.remove(bars[i])
5095 end
5096 end
5097 local br = bloodarc:Clone()
5098 br.Pos.Value = pos
5099 br.Player.Value = shooter.Name
5100 br.Parent = gamegui
5101 local dir = (camera.cframe.p - pos).unit
5102 camera:hit((-damage / 12 + 4.166666666666667) * dir)
5103 end)
5104 network:add("updatecombat", function(guy, time)
5105 if guy then
5106 lastcombat[guy] = time
5107 end
5108 end)
5109 function hud:reloadhud()
5110 pgui = player.PlayerGui
5111 maingui = wfc(pgui, "MainGui")
5112 gamegui = wfc(maingui, "GameGui")
5113 bloodscreen = wfc(gamegui, "BloodScreen")
5114 crossframe = wfc(gamegui, "CrossHud")
5115 crossparts = {
5116 wfc(crossframe, "HR"),
5117 wfc(crossframe, "HL"),
5118 wfc(crossframe, "VD"),
5119 wfc(crossframe, "VU")
5120 }
5121 ammohud = wfc(gamegui, "AmmoHud")
5122 ammofr = wfc(ammohud, "Frame")
5123 scopefr = wfc(maingui, "ScopeFrame")
5124 ammotext = wfc(ammofr, "Ammo")
5125 magtext = wfc(ammofr, "Mag")
5126 healthtext = wfc(ammofr, "Health")
5127 fmodetext = wfc(ammofr, "FMode")
5128 hitmarker = wfc(gamegui, "Hitmarker")
5129 tagfr = wfc(gamegui, "NameTag")
5130 healthbar = wfc(ammofr, "healthbar_back")
5131 healthbarFill = wfc(healthbar, "healthbar_fill")
5132 radar = wfc(gamegui, "Radar")
5133 rme = wfc(radar, "Me")
5134 rfolder = wfc(radar, "Folder")
5135 dotlist = {}
5136 rfolder:ClearAllChildren()
5137 hud:setscope(false)
5138 effects:reload()
5139 notify:reset()
5140 particle:reset()
5141 local bars = gamegui:GetChildren()
5142 for i = 1, #bars do
5143 if bars[i].Name == "BloodArc" then
5144 trash.remove(bars[i])
5145 end
5146 end
5147 local bar = ffc(maingui, "KillBar")
5148 if bar then
5149 trash.remove(bar)
5150 end
5151 for i = 1, 50 do
5152 local dot = rme:Clone()
5153 dot.Parent = rfolder
5154 dot.Visible = false
5155 dotlist[#dotlist + 1] = dot
5156 end
5157 wait(0.1)
5158 end
5159 function hud.beat()
5160 updateplayernames()
5161 updatehealth()
5162 end
5163 function hud.step()
5164 updatecross()
5165 hitmarker.ImageTransparency = hud.hitspring.p
5166 if run.time > rtime + renderinterval then
5167 updateradar()
5168 hud.gamemoderenderstep()
5169 rtime = run.time + renderinterval
5170 end
5171 if run.time > stime + spotinterval then
5172 hud.spotstep()
5173 hud.votestep()
5174 hud.gamemodestep()
5175 local sht = spot:GetChildren()
5176 for i = 1, #sht do
5177 local v = sht[i]
5178 if rtype(v, "BillboardGui") then
5179 if v.Time.Value <= 0 then
5180 trash.remove(v)
5181 else
5182 v.Time.Value = v.Time.Value - 1
5183 end
5184 end
5185 end
5186 local spottag = ffc(spotted, "Spottimer")
5187 if spottag and 0 < spottag.Timer.Value then
5188 spottag.Timer.Value = spottag.Timer.Value - 1
5189 end
5190 stime = run.time + spotinterval
5191 end
5192 end
5193end
5194print("Loading notify module")
5195do
5196 local wfc = game.WaitForChild
5197 local ffc = game.FindFirstChild
5198 local ud2 = UDim2.new
5199 local ceil = math.ceil
5200 local v3 = Vector3.new
5201 local color = Color3.new
5202 local dot = Vector3.new().Dot
5203 local workspace = workspace
5204 local ray = Ray.new
5205 local raycast = workspace.FindPartOnRayWithIgnoreList
5206 local new = Instance.new
5207 local player = game:GetService("Players").LocalPlayer
5208 local repstore = game.ReplicatedStorage
5209 local misc = repstore.Misc
5210 local pgui = player.PlayerGui
5211 local maingui = wfc(pgui, "MainGui")
5212 local gamegui = wfc(maingui, "GameGui")
5213 local framelist = wfc(gamegui, "NotifyList")
5214 local main = misc.Main
5215 local side = misc.Side
5216 local killbar = misc.KillBar
5217 local rankbar = misc.RankBar
5218 local attachbar = misc.AttachBar
5219 local typelist = {
5220 kill = {
5221 "Enemy Killed!"
5222 },
5223 collx2 = {
5224 "Double Collateral!"
5225 },
5226 collx3 = {
5227 "Triple Collateral!"
5228 },
5229 collxn = {
5230 "Multi Collateral!"
5231 },
5232 killx2 = {
5233 "Double Kill!"
5234 },
5235 killx3 = {
5236 "Triple Kill!"
5237 },
5238 killx4 = {"Quad Kill!"},
5239 killxn = {
5240 "Multi Kill!"
5241 },
5242 backstab = {"Backstab!"},
5243 assist = {"Assist!"},
5244 assistkill = {
5245 "Assist Count As Kill!"
5246 },
5247 head = {
5248 "Headshot Bonus!"
5249 },
5250 wall = {
5251 "Wallbang Bonus!"
5252 },
5253 spot = {
5254 "Spot Bonus!"
5255 },
5256 long = {
5257 "Killed from a distance!"
5258 },
5259 flagsteal = {
5260 "Acquired Enemy Flag!"
5261 },
5262 flagcapture = {
5263 "Captured Enemy Flag!"
5264 },
5265 flagteamcap = {
5266 "Team Captured Enemy Flag!"
5267 },
5268 flagrecover = {
5269 "Recovered Team Flag!"
5270 },
5271 flagdef1 = {
5272 "Killed Enemy Flag Carrier!"
5273 },
5274 flagdef2 = {
5275 "Protected Flag Carrier!"
5276 },
5277 flagdef3 = {
5278 "Denied Enemy Capture!"
5279 },
5280 flagdef4 = {
5281 "Denied Enemy Pick Up!"
5282 },
5283 flagdef5 = {
5284 "Flag Guard Kill!"
5285 },
5286 flagdef6 = {
5287 "Flag Recover Kill!"
5288 },
5289 flagsup1 = {
5290 "Flag Escort Kill!"
5291 },
5292 flagsup2 = {
5293 "Killed Enemy Flag Escort!"
5294 },
5295 flagsup3 = {
5296 "Assisted by Teammate!"
5297 },
5298 flagsup4 = {
5299 "Protected Flag Carrier Under Fire!"
5300 },
5301 flagsup5 = {
5302 "Saved by Teammate!"
5303 },
5304 flagsup6 = {
5305 "Protected by Teammate!"
5306 },
5307 flagoff1 = {
5308 "Offensive Flag Kill!"
5309 },
5310 flagoff2 = {
5311 "Denied Enemy Flag Recovery!"
5312 },
5313 flagoff3 = {
5314 "Killed Enemy Flag Guard!"
5315 },
5316 dogtagself = {
5317 "Secured Personal Tag!"
5318 },
5319 dogtagconfirm = {
5320 "Kill Confirmed!"
5321 },
5322 dogtagteam = {
5323 "Teammate Confirmed Kill!"
5324 },
5325 dogtagdeny = {
5326 "Denied Enemy Kill!"
5327 },
5328 domcap = {
5329 "Captured a position!"
5330 },
5331 domcapping = {
5332 "Capturing position"
5333 },
5334 domdefend = {
5335 "Defended a position!"
5336 },
5337 domassault = {
5338 "Assaulted a position!"
5339 },
5340 domattack = {
5341 "Attacked a position!"
5342 },
5343 dombuzz = {
5344 "Stopped an enemy capture!"
5345 },
5346 kingcap = {
5347 "Captured the hill!"
5348 },
5349 kingholding = {
5350 "Holding hill"
5351 },
5352 kingcapping = {
5353 "Capturing hill"
5354 },
5355 kingdefend = {
5356 "Defended the hill!"
5357 },
5358 kingassault = {
5359 "Assaulted the hill!"
5360 },
5361 kingattack = {
5362 "Attacked the hill!"
5363 },
5364 kingbuzz = {
5365 "Stopped enemy capture of the hill!"
5366 },
5367 [""] = {}
5368 }
5369 local function typeout(label, speed)
5370 local speed = speed or 2
5371 local text = label.Text
5372 label.Text = ""
5373 spawn(function()
5374 for i = 1, string.len(text) do
5375 if i % 2 == 0 then
5376 sound.play("ui_typeout", 0.2)
5377 end
5378 label.Text = string.sub(text, 1, speed * i)
5379 wait(0.016666666666666666)
5380 end
5381 end)
5382 end
5383 local function queuetypeout(label, speed)
5384 local speed = speed or 3
5385 local text = label.Text
5386 label.Text = ""
5387 for i = 1, string.len(text) do
5388 if i % 2 == 0 then
5389 sound.play("ui_typeout", 0.2)
5390 end
5391 label.Text = string.sub(text, 1, speed * i)
5392 wait(0.016666666666666666)
5393 end
5394 end
5395 function notify:customaward(customtext)
5396 local display = side:Clone()
5397 local primary = wfc(display, "Primary")
5398 display.Parent = framelist
5399 sound.play("ui_smallaward", 0.2)
5400 local fr = framelist:GetChildren()
5401 for i = 1, #fr do
5402 local v = fr[i]
5403 if v:IsA("Frame") and v.Parent then
5404 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
5405 end
5406 end
5407 spawn(function()
5408 primary.Text = customtext
5409 primary.TextTransparency = 0
5410 typeout(primary, 3)
5411 wait(5.5)
5412 for i = 1, 10 do
5413 primary.TextTransparency = i / 10
5414 primary.TextStrokeTransparency = i / 10 + 0.4
5415 wait(0.016666666666666666)
5416 end
5417 wait(0.1)
5418 trash.remove(display)
5419 end)
5420 end
5421 function smallaward(type, pt)
5422 local pt = pt or 25
5423 local display = side:Clone()
5424 local primary = wfc(display, "Primary")
5425 local point = wfc(display, "Point")
5426 sound.play("ui_smallaward", 0.2)
5427 display.Parent = framelist
5428 local fr = framelist:GetChildren()
5429 for i = 1, #fr do
5430 local v = fr[i]
5431 if v:IsA("Frame") and v.Parent then
5432 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
5433 end
5434 end
5435 spawn(function()
5436 point.Text = "[+" .. pt .. "]"
5437 primary.Text = typelist[type][1]
5438 if type == "head" then
5439 sound.play("headshotkill", 0.45)
5440 end
5441 point.TextTransparency = 0
5442 primary.TextTransparency = 0
5443 typeout(point, 3)
5444 typeout(primary, 3)
5445 wait(5.5)
5446 for i = 1, 10 do
5447 point.TextTransparency = i / 10
5448 primary.TextTransparency = i / 10
5449 point.TextStrokeTransparency = i / 10 + 0.4
5450 primary.TextStrokeTransparency = i / 10 + 0.4
5451 wait(0.016666666666666666)
5452 end
5453 wait(0.1)
5454 trash.remove(display)
5455 end)
5456 end
5457 function bigaward(type, victim, weap, pt, extradata)
5458 local display = main:Clone()
5459 local bk = wfc(display, "Overlay")
5460 local primary = wfc(display, "Primary")
5461 local point = wfc(display, "Point")
5462 local enemy = wfc(display, "Enemy")
5463 display.Parent = framelist
5464 local fr = framelist:GetChildren()
5465 for i = 1, #fr do
5466 local v = fr[i]
5467 if v:IsA("Frame") and v.Parent then
5468 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
5469 end
5470 end
5471 spawn(function()
5472 point.Text = "[+" .. pt .. "]"
5473 primary.Text = typelist[type][1]
5474 enemy.Text = victim or ""
5475 sound.play("ui_begin", 0.4)
5476 if type == "kill" then
5477 sound.play("killshot", 0.2)
5478 else
5479 end
5480 point.TextTransparency = 0
5481 point.TextStrokeTransparency = 0
5482 primary.TextTransparency = 0
5483 primary.TextStrokeTransparency = 0
5484 enemy.TextTransparency = 1
5485 enemy.TextStrokeTransparency = 1
5486 bk.ImageTransparency = 0.2
5487 bk:TweenSizeAndPosition(ud2(0, 200, 0, 80), ud2(0.5, -150, 0.7, -40), "Out", "Linear", 0, true)
5488 typeout(point)
5489 typeout(primary)
5490 spawn(function()
5491 wait(0.05)
5492 for i = 1, 10 do
5493 bk.ImageTransparency = i / 10
5494 wait(0.1)
5495 end
5496 bk.Size = ud2(0, 200, 0, 80)
5497 bk.Position = ud2(0.55, -100, 0.3, -40)
5498 end)
5499 bk:TweenSizeAndPosition(ud2(0, 300, 0, 30), ud2(0.5, -150, 0.7, -15), "Out", "Linear", 0.05, true)
5500 wait(0.05)
5501 bk:TweenSizeAndPosition(ud2(0, 500, 0, 8), ud2(0.5, -150, 0.7, -4), "Out", "Linear", 0.05, true)
5502 wait(1.5)
5503 for i = 1, 2 do
5504 primary.TextTransparency = 1
5505 primary.TextStrokeTransparency = 1
5506 sound.play("ui_blink", 0.4)
5507 wait(0.1)
5508 primary.TextTransparency = 0
5509 primary.TextStrokeTransparency = 0
5510 wait(0.1)
5511 end
5512 primary.TextTransparency = 1
5513 primary.TextStrokeTransparency = 1
5514 wait(0.2)
5515 enemy.TextTransparency = 0
5516 enemy.TextStrokeTransparency = 0
5517 queuetypeout(enemy, 4)
5518 primary.TextTransparency = 0
5519 primary.TextStrokeTransparency = 0
5520 primary.Position = ud2(0.5, enemy.TextBounds.x + 10, 0.7, -10)
5521 if type == "kill" then
5522 primary.Text = "[" .. weap .. "]"
5523 else
5524 primary.Text = weap
5525 end
5526 queuetypeout(primary, 4)
5527 wait(3)
5528 for i = 1, 10 do
5529 point.TextTransparency = i / 10
5530 primary.TextTransparency = i / 10
5531 enemy.TextTransparency = i / 10
5532 point.TextStrokeTransparency = i / 10 + 0.4
5533 primary.TextStrokeTransparency = i / 10 + 0.4
5534 enemy.TextStrokeTransparency = i / 10 + 0.4
5535 wait(0.016666666666666666)
5536 end
5537 wait(0.1)
5538 trash.remove(display)
5539 end)
5540 end
5541 local function unlockedgun(weapon)
5542 local br = attachbar:Clone()
5543 local title = br.Title
5544 local atext = br.Attach
5545 br.Parent = maingui
5546 br.Position = ud2(0.5, 0, 0.15, 0)
5547 title.Text = "Unlocked New Gun!"
5548 atext.Text = weapon
5549 local t0 = tick()
5550 local stop
5551 stop = run.onstep:connect(function()
5552 local t = tick() - t0
5553 atext.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
5554 title.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
5555 if t > 3 then
5556 stop()
5557 br:Destroy()
5558 end
5559 end)
5560 end
5561 local function unlockedattach(weapon, attachments, killss)
5562 for i = 1, #attachments do
5563 do
5564 local attachment = attachments[i]
5565 local kills = killss[i]
5566 local br = attachbar:Clone()
5567 local money = br.Money
5568 local title = br.Title
5569 local atext = br.Attach
5570 br.Parent = maingui
5571 br.Position = ud2(0.5, 0, 0.15, 0)
5572 title.Text = "Unlocked " .. weapon .. " Attachment"
5573 atext.Text = attachment
5574 money.Text = "[+200]"
5575 local t0 = tick()
5576 local stop
5577 stop = run.onstep:connect(function()
5578 local t = tick() - t0
5579 atext.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
5580 title.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
5581 money.TextTransparency = t < 0.5 and 1 or t < 2.5 and 0 or t < 3 and (t - 2.5) / 0.5 or 1
5582 if t > 3 then
5583 stop()
5584 br:Destroy()
5585 end
5586 end)
5587 wait(3)
5588 end
5589 end
5590 end
5591 local function rankup(old, new, newguns)
5592 local br = rankbar:Clone()
5593 local money = br.Money
5594 local title = br.Title
5595 local rtext = br.Rank
5596 local count = 0
5597 local sht = maingui:GetChildren()
5598 for i = 1, #sht do
5599 if sht[i].Name == "RankBar" or sht[i].Name == "AttachBar" then
5600 count = count + 1
5601 end
5602 end
5603 br.Parent = maingui
5604 rtext.Text = new
5605 money.Text = "+" .. 5 * (new - old) * (81 + new + old) / 2 .. " CR"
5606 local t0 = tick()
5607 local stop
5608 stop = run.onstep:connect(function()
5609 local t = tick() - t0
5610 rtext.TextTransparency = t < 3 and 0 or t < 3.5 and (t - 3) / 0.5 or 1
5611 title.TextTransparency = t < 3 and 0 or t < 3.5 and (t - 3) / 0.5 or 1
5612 money.TextTransparency = t < 0.5 and 1 or t < 3.5 and 0 or t < 4 and (t - 3.5) / 0.5 or 1
5613 if t > 4 then
5614 stop()
5615 br:Destroy()
5616 if newguns then
5617 for i = 1, #newguns do
5618 unlockedgun(newguns[i])
5619 wait(3)
5620 end
5621 end
5622 end
5623 end)
5624 end
5625 function notify:testrankup(rank)
5626 rankup(rank)
5627 end
5628 function notify:reset()
5629 maingui = wfc(pgui, "MainGui")
5630 gamegui = wfc(maingui, "GameGui")
5631 framelist = wfc(gamegui, "NotifyList")
5632 if ffc(maingui, "KillBar") then
5633 trash.remove(maingui.KillBar)
5634 end
5635 end
5636 do
5637 local cf = CFrame.new
5638 local tos = cf().toObjectSpace
5639 local bcolor = BrickColor.new
5640 local repstore = game.ReplicatedStorage
5641 local gunmodels = repstore.GunModels
5642 local gunmodules = repstore.GunModules
5643 local attmodels = repstore.AttachmentModels
5644 local mpgunmodels = repstore.MeshPartGunModels
5645 local function hideparts(wepmodel, atttype, hide)
5646 local parts = wepmodel:GetChildren()
5647 local slottag
5648 for i = 1, #parts do
5649 if atttype == "Optics" then
5650 if parts[i].Name == "Iron" or parts[i].Name == "IronGlow" then
5651 if hide and not ffc(parts[i], "Hide") then
5652 local tag = new("IntValue", parts[i])
5653 tag.Name = "Hide"
5654 else
5655 local tag = ffc(parts[i], "Hide")
5656 if tag then
5657 tag:Destroy()
5658 end
5659 end
5660 parts[i].Transparency = hide and 1 or 0
5661 elseif parts[i].Name == "SightMark" and ffc(parts[i], "Decal") then
5662 parts[i].Decal.Transparency = hide and 1 or 0
5663 end
5664 elseif atttype == "Underbarrel" and parts[i].Name == "Grip" then
5665 if hide and not ffc(parts[i], "Hide") then
5666 local tag = new("IntValue", parts[i])
5667 tag.Name = "Hide"
5668 else
5669 local tag = ffc(parts[i], "Hide")
5670 if tag then
5671 tag:Destroy()
5672 end
5673 end
5674 parts[i].Transparency = hide and 1 or 0
5675 slottag = ffc(parts[i], "Slot1") or ffc(parts[i], "Slot2")
5676 end
5677 end
5678 return slottag
5679 end
5680 local function texturemodel(wepmodel, attachdata, camodata)
5681 local root = camodata
5682 for i, part in next, wepmodel:GetChildren() do
5683 if ffc(part, "Mesh") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
5684 part.Anchored = true
5685 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
5686 if slottag then
5687 for x, y in next, part:GetChildren() do
5688 if y:IsA("Texture") then
5689 y:Destroy()
5690 end
5691 end
5692 if root and root[slottag.Name] and root[slottag.Name].Name ~= "" then
5693 local t = Instance.new("Texture")
5694 t.Name = slottag.Name
5695 t.Texture = "rbxassetid://" .. root[slottag.Name].TextureProperties.TextureId
5696 t.Transparency = part.Transparency >= 0.8 and 1 or root[slottag.Name].TextureProperties.Transparency
5697 t.StudsPerTileU = root[slottag.Name].TextureProperties.StudsPerTileU
5698 t.StudsPerTileV = root[slottag.Name].TextureProperties.StudsPerTileV
5699 if root[slottag.Name].TextureProperties.Color then
5700 local colordata = root[slottag.Name].TextureProperties.Color
5701 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
5702 end
5703 for x = 0, (part:IsA("MeshPart") or part:IsA("UnionOperation")) and 5 or 0 do
5704 local tt = t:Clone()
5705 tt.Face = x
5706 tt.Parent = part
5707 end
5708 t:Destroy()
5709 if not root[slottag.Name].BrickProperties.DefaultColor then
5710 if part:IsA("UnionOperation") then
5711 part.UsePartColor = true
5712 end
5713 if root[slottag.Name].BrickProperties.Color then
5714 local colordata = root[slottag.Name].BrickProperties.Color
5715 part.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
5716 else
5717 part.BrickColor = bcolor(root[slottag.Name].BrickProperties.BrickColor)
5718 end
5719 end
5720 if root[slottag.Name].BrickProperties.Material then
5721 part.Material = root[slottag.Name].BrickProperties.Material
5722 end
5723 end
5724 end
5725 elseif part:IsA("Model") then
5726 texturemodel(part)
5727 end
5728 end
5729 end
5730 local function updategunmeshtype(wepmodel, attachdata, camodata)
5731 local root = camodata
5732 local meshpartmap = {}
5733 local mpmodel = ffc(mpgunmodels, wepmodel.Name)
5734 if mpmodel then
5735 for i, v in next, mpmodel:GetChildren() do
5736 if v:IsA("MeshPart") then
5737 meshpartmap[v.MeshId] = v
5738 end
5739 end
5740 end
5741 for i, v in next, wepmodel:GetChildren() do
5742 if ffc(v, "Mesh") or v:IsA("MeshPart") or v:IsA("UnionOperation") then
5743 v.Anchored = true
5744 v.CanCollide = false
5745 local slottag = ffc(v, "Slot1") or ffc(v, "Slot2")
5746 if slottag and root and root[slottag.Name] and root[slottag.Name].BrickProperties and root[slottag.Name].BrickProperties.EnableMaterial and ffc(v, "Mesh") and meshpartmap[v.Mesh.MeshId] then
5747 local mpart = meshpartmap[v.Mesh.MeshId]:Clone()
5748 mpart.CFrame = v.CFrame
5749 mpart.Name = v.Name
5750 mpart.Anchored = true
5751 mpart.Parent = wepmodel
5752 mpart.Color = v.Color
5753 mpart.Material = v.Material
5754 mpart.CanCollide = v.CanCollide
5755 mpart.Transparency = v.Transparency
5756 for x, y in next, v:GetChildren() do
5757 if y.Name == "Texture" then
5758 y:Clone().Parent = mpart
5759 end
5760 end
5761 v:Destroy()
5762 end
5763 end
5764 end
5765 end
5766 local function updategunattachment(wepmodel, atttype, attachname, wepnodes, preview)
5767 local parts = wepmodel:GetChildren()
5768 local data = require(ffc(gunmodules, wepmodel.Name))
5769 local attachdata = data.attachments[atttype] and data.attachments[atttype][attachname] or {}
5770 local refmodel = attachdata.altmodel and ffc(attmodels, attachdata.altmodel) or ffc(attmodels, attachname)
5771 if not refmodel then
5772 return
5773 end
5774 local model = refmodel:Clone()
5775 local basepart = wfc(model, "Node")
5776 local sidemount = attachdata.sidemount and attmodels[attachdata.sidemount]:Clone()
5777 local node
5778 model.Name = attachname
5779 if sidemount then
5780 local basenode = sidemount.Node
5781 local mountnode = attachdata.mountnode and wepnodes[attachdata.mountnode] or atttype == "Optics" and wepnodes.MountNode or atttype == "Underbarrel" and wepnodes.UnderMountNode
5782 local mountcframes = {}
5783 local mchildren = sidemount:GetChildren()
5784 local basecframe = basenode.CFrame
5785 for i = 1, #mchildren do
5786 if mchildren[i]:IsA("BasePart") then
5787 mountcframes[i] = tos(basecframe, mchildren[i].CFrame)
5788 end
5789 end
5790 basenode.CFrame = mountnode.CFrame
5791 for i = 1, #mchildren do
5792 if mchildren[i]:IsA("BasePart") then
5793 local v = mchildren[i]
5794 v.CFrame = mountnode.CFrame * mountcframes[i]
5795 end
5796 end
5797 node = attachdata.node and wepnodes[attachdata.node] or sidemount[atttype .. "Node"]
5798 sidemount.Parent = model
5799 else
5800 node = attachdata.node and wepnodes[attachdata.node] or wepnodes[atttype .. "Node"]
5801 end
5802 local weldcframes = {}
5803 local children = model:GetChildren()
5804 local basecframe = basepart and basepart.CFrame
5805 local slottag
5806 if atttype == "Optics" or atttype == "Underbarrel" then
5807 slottag = hideparts(wepmodel, atttype, true)
5808 end
5809 for i = 1, #children do
5810 if children[i]:IsA("BasePart") then
5811 weldcframes[i] = tos(basecframe, children[i].CFrame)
5812 end
5813 end
5814 basepart.CFrame = node.CFrame
5815 for i = 1, #children do
5816 if children[i]:IsA("BasePart") then
5817 local v = children[i]
5818 v.CFrame = node.CFrame * weldcframes[i]
5819 if slottag and (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart")) then
5820 slottag:Clone().Parent = v
5821 end
5822 end
5823 end
5824 model.Parent = wepmodel
5825 end
5826 function getgunmodel(wep, attachdata, camodata)
5827 local findgun = ffc(gunmodels, wep)
5828 if findgun then
5829 local wepmodel = findgun:Clone()
5830 local nodes = wfc(wepmodel, "MenuNodes")
5831 nodes.Parent = wepmodel
5832 wepmodel.PrimaryPart = wfc(nodes, "MenuNode")
5833 for i, v in next, attachdata, nil do
5834 if v ~= "" then
5835 updategunattachment(wepmodel, i, v, nodes)
5836 end
5837 end
5838 updategunmeshtype(wepmodel, attachdata, camodata)
5839 texturemodel(wepmodel, attachdata, camodata)
5840 return wepmodel
5841 end
5842 end
5843 end
5844 network:add("killed", function(killer, part, deathcf, weapon, rank, attachdata, camodata)
5845 char.deadcf = deathcf
5846 if killer == player then
5847 camera:setfixedcam(CFrame.new(deathcf.p, deathcf.p + deathcf.lookVector))
5848 else
5849 do
5850 local gunmodel = getgunmodel(weapon, attachdata, camodata)
5851 gunmodel.Parent = workspace.CurrentCamera
5852 gunmodel:SetPrimaryPartCFrame(deathcf * CFrame.Angles(0, math.rad(90), 0) + Vector3.new(0, 1, 0))
5853 local newbar = killbar:Clone()
5854 newbar.Killer.Label.Text = killer.Name
5855 newbar.Weapon.Label.Text = weapon
5856 newbar.Parent = maingui
5857 newbar.Rank.Label.Text = rank
5858 local wepnote = misc.WepNote:Clone()
5859 wepnote.Parent = gunmodel
5860 for i, v in next, newbar.Attachments:GetChildren() do
5861 v.Type.Text = "None"
5862 end
5863 if attachdata then
5864 for i, v in next, attachdata, nil do
5865 if i ~= "Name" and v ~= "" then
5866 newbar.Attachments[i].Type.Text = v
5867 end
5868 end
5869 end
5870 camera:setspectate(killer, part)
5871 delay(5, function()
5872 gunmodel:Destroy()
5873 end)
5874 end
5875 end
5876 end)
5877 network:add("unlockedattach", unlockedattach)
5878 network:add("rankup", rankup)
5879 network:add("bigaward", function(type, victim, weapon, pt, extradata)
5880 bigaward(type, victim, weapon, pt, extradata)
5881 end)
5882 network:add("smallaward", function(type, pt)
5883 smallaward(type, pt)
5884 end)
5885 function notify.step()
5886 if char.health <= 0 then
5887 local bar = ffc(maingui, "KillBar")
5888 if bar then
5889 local enemy = ffc(game:GetService("Players"), bar.Killer.Label.Text)
5890 if enemy then
5891 local health = network:fetch("getkillerhealth", enemy)
5892 bar.Health.Label.Text = ceil(health)
5893 bar.Health.Label.TextColor3 = health < 20 and color(1, 0, 0) or health < 50 and color(1, 1, 0) or color(0, 1, 0)
5894 end
5895 end
5896 end
5897 end
5898end
5899print("Loading leaderboard module")
5900do
5901 local wfc = game.WaitForChild
5902 local ffc = game.FindFirstChild
5903 local ud2 = UDim2.new
5904 local ceil = math.ceil
5905 local cf = CFrame.new
5906 local v3 = Vector3.new
5907 local color = Color3.new
5908 local dot = Vector3.new().Dot
5909 local workspace = workspace
5910 local ray = Ray.new
5911 local new = Instance.new
5912 local raycast = workspace.FindPartOnRayWithIgnoreList
5913 local infolder = function(l, e)
5914 for i = 1, #l do
5915 if l[i].Name == e then
5916 return l[i]
5917 end
5918 end
5919 end
5920 local rtype = game.IsA
5921 local debris = game.Debris
5922 local player = game:GetService("Players").LocalPlayer
5923 local playertag = game.ReplicatedStorage.Character.PlayerTag
5924 local pgui = player.PlayerGui
5925 local misc = input.consoleon and game.ReplicatedStorage.XBOX or game.ReplicatedStorage.Misc
5926 local playerstat = misc.Player
5927 local board = wfc(pgui, "Leaderboard")
5928 if input.consoleon then
5929 board:Destroy()
5930 board = misc.Leaderboard:Clone()
5931 board.Parent = pgui
5932 end
5933 local main = wfc(board, "Main")
5934 local global = wfc(board, "Global")
5935 local ghost = wfc(main, "Ghosts")
5936 local phantom = wfc(main, "Phantoms")
5937 local gdataframe = wfc(ghost, "DataFrame")
5938 local pdataframe = wfc(phantom, "DataFrame")
5939 local ghostdata = wfc(gdataframe, "Data")
5940 local phantomdata = wfc(pdataframe, "Data")
5941 local spacing = input.consoleon and 30 or 25
5942 local function organize()
5943 local pp = game:GetService("Players"):GetPlayers()
5944 for i = 1, #pp do
5945 local v = pp[i]
5946 local rightparent = v.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
5947 local wrongparent = v.TeamColor ~= game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
5948 local right = ffc(rightparent, v.Name)
5949 local wrong = ffc(wrongparent, v.Name)
5950 if not right and wrong then
5951 wrong.Parent = rightparent
5952 end
5953 end
5954 local gd = ghostdata:GetChildren()
5955 table.sort(gd, function(a, b)
5956 return tonumber(a.Score.Text) > tonumber(b.Score.Text)
5957 end)
5958 for i = 1, #gd do
5959 local v = gd[i]
5960 v.Position = ud2(0, 0, 0, i * spacing)
5961 if v.Name == player.Name then
5962 v.Username.TextColor3 = color(1, 1, 0)
5963 end
5964 end
5965 ghostdata.Parent.CanvasSize = ud2(0, 0, 0, (#gd + 1) * spacing)
5966 local pd = phantomdata:GetChildren()
5967 table.sort(pd, function(a, b)
5968 return tonumber(a.Score.Text) > tonumber(b.Score.Text)
5969 end)
5970 for i = 1, #pd do
5971 local v = pd[i]
5972 v.Position = ud2(0, 0, 0, i * spacing)
5973 if v.Name == player.Name then
5974 v.Username.TextColor3 = color(1, 1, 0)
5975 end
5976 end
5977 phantomdata.Parent.CanvasSize = ud2(0, 0, 0, (#pd + 1) * spacing)
5978 end
5979 local function addplayer(guy)
5980 local gbar = ffc(ghostdata, guy.Name)
5981 local pbar = ffc(phantomdata, guy.Name)
5982 if gbar or pbar then
5983 return
5984 end
5985 local bar = playerstat:Clone()
5986 bar.Name = guy.Name
5987 bar.Username.Text = guy.Name
5988 bar.Kills.Text = 0
5989 bar.Deaths.Text = 0
5990 bar.Streak.Text = 0
5991 bar.Score.Text = 0
5992 bar.Kdr.Text = 0
5993 bar.Rank.Text = 0
5994 if guy == player then
5995 bar.Username.TextColor3 = color(1, 1, 0)
5996 end
5997 bar.Parent = guy.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
5998 organize()
5999 end
6000 local function removeplayer(guy)
6001 local gbar = ffc(ghostdata, guy.Name)
6002 local pbar = ffc(phantomdata, guy.Name)
6003 if gbar then
6004 trash.remove(gbar)
6005 end
6006 if pbar then
6007 trash.remove(pbar)
6008 end
6009 organize()
6010 end
6011 local function updatestats(guy, data)
6012 local rightparent = guy.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6013 local bar = ffc(rightparent, guy.Name)
6014 if not bar then
6015 organize()
6016 bar = ffc(rightparent, guy.Name)
6017 end
6018 if bar then
6019 for i, v in next, data, nil do
6020 bar[i].Text = v
6021 end
6022 end
6023 organize()
6024 end
6025 function leaderboard:show()
6026 main.Visible = true
6027 end
6028 function leaderboard:hide()
6029 main.Visible = false
6030 end
6031 network:add("removeplayer", removeplayer)
6032 network:add("newplayer", addplayer)
6033 network:add("updatestats", updatestats)
6034 organize()
6035 game:GetService("UserInputService").InputBegan:connect(function(keycode)
6036 local key = keycode.KeyCode
6037 if key == Enum.KeyCode.Tab and not input.iskeydown(Enum.KeyCode.LeftAlt) then
6038 if main.Visible then
6039 leaderboard:hide()
6040 else
6041 organize()
6042 leaderboard:show()
6043 end
6044 end
6045 end)
6046end
6047print("Loading char module")
6048do
6049 local rtype = game.IsA
6050 local next = next
6051 local new = Instance.new
6052 local wfc = game.WaitForChild
6053 local ffc = game.FindFirstChild
6054 local getchildren = game.GetChildren
6055 local workspace = game.Workspace
6056 local cf = CFrame.new
6057 local vtws = CFrame.new().vectorToWorldSpace
6058 local angles = CFrame.Angles
6059 local nc = cf()
6060 local v3 = Vector3.new
6061 local nv = v3()
6062 local ray = Ray.new
6063 local raycast = workspace.FindPartOnRayWithIgnoreList
6064 local debris = game.Debris
6065 local dot = nv.Dot
6066 local ud2 = UDim2.new
6067 local abs = math.abs
6068 local tos = cf().toObjectSpace
6069 local player = game:GetService("Players").LocalPlayer
6070 local pgui = player.PlayerGui
6071 local repstore = game.ReplicatedStorage
6072 local repchar = repstore.Character
6073 local attmodels = repstore.AttachmentModels
6074 local character, humanoid, rootpart, rootjoint, statsloaded
6075 local thread = sequencer.new()
6076 local weapon
6077 local aiming = false
6078 local auto = false
6079 local burst = 0
6080 local reloading = false
6081 local sprinting = false
6082 local animating = false
6083 local stability = 0
6084 local basewalkspeed = 14
6085 local sprintspring = physics.spring.new()
6086 local climbing = physics.spring.new()
6087 local curgunid = 0
6088 local aimspring = physics.spring.new()
6089 local zoommodspring = physics.spring.new(1)
6090 zoommodspring.s = 12
6091 zoommodspring.d = 0.95
6092 local loadedgundata = {}
6093 char.unaimedfov = 80
6094 function char.setunaimedfov(value)
6095 char.unaimedfov = value
6096 end
6097 function char.addgun(gundata)
6098 for i = 1, curgunid do
6099 if loadedgundata[i] == gundata then
6100 error("Error, tried to add gun twice")
6101 break
6102 end
6103 end
6104 curgunid = curgunid + 1
6105 loadedgundata[curgunid] = gundata
6106 gundata.id = curgunid
6107 return curgunid
6108 end
6109 function char.removegun(gundata)
6110 local found
6111 for i = 1, curgunid do
6112 if loadedgundata[i] == gundata then
6113 found = true
6114 break
6115 end
6116 end
6117 if not found then
6118 error("Error, tried to remove gun twice")
6119 end
6120 local gunid = gundata.id
6121 gundata.id = nil
6122 loadedgundata[gunid] = loadedgundata[curgunid]
6123 loadedgundata[curgunid] = nil
6124 curgunid = curgunid - 1
6125 local replacement = loadedgundata[gunid]
6126 if replacement then
6127 replacement.id = gunid
6128 end
6129 end
6130 function char.unloadguns()
6131 curgunid = 0
6132 loadedgundata = {}
6133 end
6134 local swingspring = physics.spring.new(nv)
6135 local speedspring = physics.spring.new()
6136 local velocityspring = physics.spring.new(nv)
6137 local pronespring = physics.spring.new(0)
6138 local truespeedspring = physics.spring.new(0)
6139 local equipspring = physics.spring.new(1)
6140 local muzzlespring = physics.spring.new(0)
6141 local walkspeedmult = 1
6142 sprintspring.s = 12
6143 sprintspring.d = 0.9
6144 climbing.s = 12
6145 climbing.d = 0.9
6146 aimspring.d = 0.9
6147 swingspring.s = 10
6148 swingspring.d = 0.75
6149 speedspring.s = 16
6150 velocityspring.s = 16
6151 pronespring.s = 8
6152 truespeedspring.s = 8
6153 equipspring.s = 12
6154 equipspring.d = 0.75
6155 local ignore = {
6156 workspace.Ignore,
6157 game.Workspace.CurrentCamera
6158 }
6159 local backwardsmult = 0.8
6160 local bodyforce = new("BodyVelocity")
6161 bodyforce.Name = "\n"
6162 local muzzlelight, walkspeedspring, headheightspring, updatewalkspeed
6163 walkspeedspring = physics.spring.new(basewalkspeed)
6164 walkspeedspring.s = 8
6165 headheightspring = physics.spring.new(1.5)
6166 headheightspring.s = 8
6167 char.acceleration = nv
6168 bodyforce.MaxForce = nv
6169 local jumpallowed
6170 do
6171 local movementmode = "stand"
6172 local down = v3(0, -5, 0)
6173 function updatewalkspeed()
6174 if sprinting then
6175 walkspeedspring.t = 1.4 * walkspeedmult * basewalkspeed
6176 elseif movementmode == "prone" then
6177 walkspeedspring.t = walkspeedmult * basewalkspeed / 4
6178 elseif movementmode == "crouch" then
6179 walkspeedspring.t = walkspeedmult * basewalkspeed / 2
6180 elseif movementmode == "stand" then
6181 walkspeedspring.t = walkspeedmult * basewalkspeed
6182 end
6183 end
6184 local function setmovementmode(self, mode, dive)
6185 local oldmode = char.movementmode
6186 char.movementmode = mode
6187 movementmode = mode
6188 if mode == "prone" then
6189 if not dive and oldmode ~= mode then
6190 sound.play("stanceProne", 0.15)
6191 end
6192 headheightspring.t = -1.5
6193 pronespring.t = 1
6194 walkspeedspring.t = walkspeedmult * basewalkspeed / 4
6195 hud:setcrossscale(0.5)
6196 stability = 0.25
6197 if dive and sprinting then
6198 spawn(function()
6199 local lkvector = rootpart.CFrame.lookVector
6200 rootpart.Velocity = lkvector * 50 + v3(0, 40, 0)
6201 wait(0.1)
6202 rootpart.Velocity = lkvector * 60 + v3(0, 30, 0)
6203 wait(0.4)
6204 rootpart.Velocity = lkvector * 20 + v3(0, -10, 0)
6205 end)
6206 end
6207 elseif mode == "crouch" then
6208 if not dive and oldmode ~= mode then
6209 sound.play("stanceStandCrouch", 0.15)
6210 end
6211 headheightspring.t = 0
6212 pronespring.t = 0
6213 walkspeedspring.t = walkspeedmult * basewalkspeed / 2
6214 hud:setcrossscale(0.75)
6215 stability = 0.15
6216 if dive and sprinting and humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
6217 isSliding = true
6218 sound.play("slideStart", 0.25)
6219 spawn(function()
6220 local lkvector = rootpart.CFrame.lookVector
6221 local released
6222 bodyforce.MaxForce = v3(40000, 10, 40000)
6223 for i = 1, 20 do
6224 if input.keyboard.down.leftshift then
6225 lkvector = rootpart.CFrame.lookVector
6226 end
6227 bodyforce.Velocity = lkvector * (40 - i * 1.5) + v3(0, 0, 0)
6228 wait(0.03333333333333333)
6229 end
6230 bodyforce.MaxForce = nv
6231 bodyforce.Velocity = nv
6232 if isSliding then
6233 isSliding = false
6234 sound.play("slideEnd", 0.15)
6235 end
6236 end)
6237 end
6238 elseif mode == "stand" then
6239 if oldmode ~= mode then
6240 sound.play("stanceStandCrouch", 0.15)
6241 end
6242 headheightspring.t = 1.5
6243 pronespring.t = 0
6244 walkspeedspring.t = walkspeedmult * basewalkspeed
6245 hud:setcrossscale(1)
6246 stability = 0
6247 end
6248 network:send("s" .. "t" .. "a" .. "n" .. "c" .. "e", mode)
6249 sprinting = false
6250 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
6251 sprintspring.t = 0
6252 end
6253 function char.getstate()
6254 return humanoid:GetState()
6255 end
6256 function char:sprinting()
6257 return sprinting
6258 end
6259 char.setmovementmode = setmovementmode
6260 function char:setbasewalkspeed(newspeed)
6261 basewalkspeed = newspeed
6262 updatewalkspeed()
6263 end
6264 function char:setsprint(on)
6265 if on then
6266 if isSliding then
6267 isSliding = false
6268 sound.play("slideEnd", 0.15)
6269 end
6270 setmovementmode(nil, "stand")
6271 sprinting = true
6272 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
6273 auto = false
6274 burst = 0
6275 if weapon and aiming and weapon.type ~= "KNIFE" then
6276 print("un aim herE")
6277 weapon:setaim(false)
6278 end
6279 walkspeedmult = 1
6280 if not reloading and not animating then
6281 sprintspring.t = 1
6282 end
6283 walkspeedspring.t = 1.5 * walkspeedmult * basewalkspeed
6284 elseif sprinting then
6285 sprinting = false
6286 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
6287 sprintspring.t = 0
6288 walkspeedspring.t = walkspeedmult * basewalkspeed
6289 if input.mouse.down.right and weapon and weapon.type ~= "KNIFE" then
6290 weapon:setaim(true)
6291 end
6292 end
6293 end
6294 local function parkour()
6295 if weapon and not reloading and not char.grenadehold then
6296 weapon:playanimation("parkour")
6297 end
6298 sound.play("parkour", 0.25)
6299 bodyforce.MaxForce = nv
6300 local bp = new("BodyPosition")
6301 bp.Name = "\n"
6302 bp.position = rootpart.Position + rootpart.CFrame.lookVector.unit * char.speed * 1.5 + v3(0, 10, 0)
6303 bp.maxForce = v3(5000000, 500000, 500000)
6304 bp.P = 4000
6305 bp.Parent = rootpart
6306 debris:AddItem(bp, 0.45)
6307 end
6308 function char:jump(height)
6309 local rootcf = rootpart.CFrame
6310 local isonground = raycast(workspace, ray(rootcf.p, vtws(rootcf, down)), {
6311 workspace.CurrentCamera
6312 })
6313 local v = rootpart.Velocity.y
6314 local j = height and (2 * game.Workspace.Gravity * height) ^ 0.5 or 40
6315 local jumppower
6316 if v < 0 then
6317 jumppower = j
6318 else
6319 jumppower = (v * v + j * j) ^ 0.5
6320 end
6321 if isonground then
6322 if movementmode == "prone" or movementmode == "crouch" then
6323 setmovementmode(nil, "stand")
6324 elseif not aiming then
6325 local r1 = ray(rootpart.CFrame.p + v3(0, 1.5, 0), rootpart.CFrame.lookVector * 25 + v3(0, 2, 0))
6326 local h1, e1 = raycast(workspace, r1, {
6327 character,
6328 camera.currentcamera
6329 })
6330 local r2 = ray(rootpart.CFrame.p - v3(0, 1, 0), rootpart.CFrame.lookVector * 25 - v3(0, 1, 0))
6331 local h2, e2 = raycast(workspace, r2, {
6332 character,
6333 camera.currentcamera
6334 })
6335 local r3 = ray(rootpart.CFrame.p - v3(0, 1.5, 0), rootpart.CFrame.lookVector * 25 - v3(0, 1.5, 0))
6336 local h3, e3 = raycast(workspace, r3, {
6337 character,
6338 camera.currentcamera
6339 })
6340 if h3 and h1 ~= h3 and (e3 - e2).Magnitude < 0.7 and (e3 - e1).Magnitude > 4 and (e3 - rootpart.Position).Magnitude < char.speed / 1.5 and not h3:IsA("TrussPart") then
6341 parkour()
6342 delay(0.1, function()
6343 end)
6344 else
6345 humanoid.JumpPower = jumppower
6346 jumpallowed = true
6347 humanoid.Jump = true
6348 jumpallowed = false
6349 end
6350 else
6351 humanoid.JumpPower = jumppower
6352 jumpallowed = true
6353 humanoid.Jump = true
6354 jumpallowed = false
6355 end
6356 end
6357 end
6358 end
6359 local equipping = false
6360 local zooming = false
6361 local rweld, lweld, larm, rarm, lmodel, rmodel, lmain, rmain
6362 local sin = math.sin
6363 local cos = math.cos
6364 char.grenadehold = false
6365 local function gunbob(a, r)
6366 local a, r = a or 1, r or 1
6367 local d, s, v = char.distance * 6.28318 * 3 / 4, char.speed, -char.velocity
6368 if s < basewalkspeed then
6369 local w = v3(r * sin(d / 4 - 1) / 256 + r * (sin(d / 64) - r * v.z / 4) / 512, r * cos(d / 128) / 128 - r * cos(d / 8) / 256, r * sin(d / 8) / 128 + r * v.x / 1024) * s / 20 * 6.28318
6370 return cf(r * cos(d / 8 - 1) * s / 196, 1.25 * a * sin(d / 4) * s / 512, 0) * cframe.fromaxisangle(w)
6371 else
6372 local w = v3((r * sin(d / 4 - 1) / 256 + r * (sin(d / 64) - r * v.z / 4) / 512) * s / 20 * 6.28318, (r * cos(d / 128) / 128 - r * cos(d / 8) / 256) * s / 20 * 6.28318, r * sin(d / 8) / 128 * (5 * s - 56) / 20 * 6.28318 + r * v.x / 1024)
6373 return cf(r * cos(d / 8 - 1) * (5 * s - 56) / 196, 1.25 * a * sin(d / 4) * s / 512, 0) * cframe.fromaxisangle(w)
6374 end
6375 end
6376 local function gunsway(a)
6377 local d, s = tick() * 6, 2 * (1.1 - a)
6378 return cf(cos(d / 8) * s / 128, -sin(d / 4) * s / 128, sin(d / 16) * s / 64)
6379 end
6380 local asdf = function()
6381 end
6382 local function weldattachment(gun, type, attname, menunode, mainpart, attdata, welddata, menunodes)
6383 local refmodel = attdata.altmodel and ffc(attmodels, attdata.altmodel) or ffc(attmodels, attname)
6384 local copies = attdata.copy or 0
6385 local slottag
6386 if refmodel then
6387 for i = 0, copies do
6388 local model = refmodel:Clone()
6389 local attnode = model.Node
6390 local weldcframes = {}
6391 local maincf = attnode.CFrame
6392 local parts = getchildren(model)
6393 for i = 1, #parts do
6394 local v = parts[i]
6395 if v:IsA("BasePart") then
6396 weldcframes[v] = tos(maincf, v.CFrame)
6397 end
6398 end
6399 attnode.CFrame = i == 0 and menunode.CFrame or menunodes[attdata.copynodes[i]].CFrame
6400 if type == "Optics" then
6401 local del = gun:GetChildren()
6402 for i = 1, #del do
6403 if del[i].Name == "Iron" or del[i].Name == "IronGlow" or del[i].Name == "SightMark" and not ffc(del[i], "Stay") then
6404 del[i]:Destroy()
6405 end
6406 end
6407 elseif type == "Underbarrel" then
6408 local del = gun:GetChildren()
6409 for i = 1, #del do
6410 if del[i].Name == "Grip" then
6411 slottag = ffc(del[i], "Slot1") or ffc(del[i], "Slot2")
6412 del[i]:Destroy()
6413 end
6414 end
6415 end
6416 if attdata.replacemag then
6417 local del = gun:GetChildren()
6418 for x = 1, #del do
6419 if i == 0 and del[x].Name == "Mag" or i > 0 and del[x].Name == "Mag" .. i + 1 then
6420 del[x]:Destroy()
6421 end
6422 end
6423 end
6424 for x = 1, #parts do
6425 local v = parts[x]
6426 if v:IsA("BasePart") then
6427 local weld, c0
6428 if v ~= attnode then
6429 c0 = tos(mainpart.CFrame, attnode.CFrame)
6430 weld = new("Weld", mainpart)
6431 weld.Part0 = mainpart
6432 weld.Part1 = v
6433 weld.C0 = c0 * weldcframes[v]
6434 v.CFrame = mainpart.CFrame * weld.C0
6435 end
6436 if slottag and v:IsA("UnionOperation") then
6437 slottag:Clone().Parent = v
6438 end
6439 if attdata.replacemag and v.Name == "AttMag" then
6440 local magname = i == 0 and "Mag" or i > 0 and "Mag" .. i + 1
6441 v.Name = magname
6442 welddata[magname] = {
6443 part = v,
6444 weld = weld,
6445 basec0 = c0 * weldcframes[v],
6446 basetransparency = v.Transparency
6447 }
6448 end
6449 v.Anchored = false
6450 v.CanCollide = false
6451 v.Parent = gun
6452 end
6453 end
6454 attnode:Destroy()
6455 model:Destroy()
6456 end
6457 end
6458 return slottag
6459 end
6460 local function texturemodel(root, model)
6461 local bcolor = BrickColor.new
6462 for i, part in next, model:GetChildren() do
6463 if ffc(part, "Mesh") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
6464 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
6465 if slottag and slottag.Name then
6466 for x, y in next, part:GetChildren() do
6467 if y:IsA("Texture") then
6468 y:Destroy()
6469 end
6470 end
6471 if root[slottag.Name] and root[slottag.Name].Name ~= "" then
6472 if not effects.disable1pcamoskins then
6473 local t = Instance.new("Texture")
6474 t.Name = slottag.Name
6475 t.Texture = "rbxassetid://" .. root[slottag.Name].TextureProperties.TextureId
6476 t.Transparency = part.Transparency == 1 and 1 or root[slottag.Name].TextureProperties.Transparency
6477 t.StudsPerTileU = root[slottag.Name].TextureProperties.StudsPerTileU
6478 t.StudsPerTileV = root[slottag.Name].TextureProperties.StudsPerTileV
6479 if root[slottag.Name].TextureProperties.Color then
6480 local colordata = root[slottag.Name].TextureProperties.Color
6481 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6482 end
6483 for x = 0, (part:IsA("MeshPart") or part:IsA("UnionOperation")) and 5 or 0 do
6484 local tt = t:Clone()
6485 tt.Face = x
6486 tt.Parent = part
6487 end
6488 t:Destroy()
6489 end
6490 if not root[slottag.Name].BrickProperties.DefaultColor then
6491 if part:IsA("UnionOperation") then
6492 part.UsePartColor = true
6493 end
6494 local colordata = root[slottag.Name].BrickProperties.Color
6495 if colordata then
6496 part.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6497 else
6498 part.BrickColor = bcolor(root[slottag.Name].BrickProperties.BrickColor)
6499 end
6500 end
6501 if root[slottag.Name].BrickProperties.Material then
6502 part.Material = root[slottag.Name].BrickProperties.Material
6503 end
6504 end
6505 end
6506 elseif part:IsA("Model") then
6507 texturemodel(root, part)
6508 end
6509 end
6510 end
6511 local tos = CFrame.new().toObjectSpace
6512 local mpgunmodels = game.ReplicatedStorage.MeshPartGunModels
6513 local function weldmodel(model, mainpart, attachlist, data, camodata)
6514 local welddata = {}
6515 local parts = model:GetChildren()
6516 local maincf = mainpart.CFrame
6517 local menunodes = ffc(model, "MenuNodes")
6518 local meshpartmap = {}
6519 local mpmodel = ffc(mpgunmodels, model.Name)
6520 if mpmodel then
6521 for i, v in next, mpmodel:GetChildren() do
6522 if v:IsA("MeshPart") then
6523 meshpartmap[v.MeshId] = v
6524 end
6525 end
6526 end
6527 for i = 1, #parts do
6528 local part = parts[i]
6529 if part ~= mainpart and part:IsA("BasePart") then
6530 local name = part.Name
6531 if ffc(part, "Mesh") then
6532 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
6533 if slottag and slottag.Name and camodata and camodata[slottag.Name] and camodata[slottag.Name].BrickProperties and camodata[slottag.Name].BrickProperties.EnableMaterial and ffc(part, "Mesh") and meshpartmap[part.Mesh.MeshId] then
6534 local mpart = meshpartmap[part.Mesh.MeshId]:Clone()
6535 mpart.Parent = model
6536 mpart.Name = name
6537 mpart.CFrame = part.CFrame
6538 part:Destroy()
6539 part = mpart
6540 parts[i] = part
6541 end
6542 end
6543 end
6544 end
6545 for i = 1, #parts do
6546 local part = parts[i]
6547 if part ~= mainpart and part:IsA("BasePart") then
6548 local name = part.Name
6549 if data and data.weldexception and data.weldexception[name] and ffc(model, data.weldexception[name]) then
6550 local nbase = model[data.weldexception[name]]
6551 local nmaincf = nbase.CFrame
6552 local c0 = tos(nmaincf, part.CFrame)
6553 local weld = new("Weld", mainpart)
6554 weld.Part0 = nbase
6555 weld.Part1 = part
6556 weld.C0 = c0
6557 part.CFrame = maincf * c0
6558 welddata[name] = {
6559 part = part,
6560 weld = weld,
6561 basec0 = c0,
6562 basetransparency = part.Transparency
6563 }
6564 else
6565 local c0 = tos(maincf, part.CFrame)
6566 local weld = new("Weld", mainpart)
6567 weld.Part0 = mainpart
6568 weld.Part1 = part
6569 weld.C0 = c0
6570 part.CFrame = maincf * c0
6571 welddata[name] = {
6572 part = part,
6573 weld = weld,
6574 basec0 = c0,
6575 basetransparency = part.Transparency
6576 }
6577 end
6578 part.Anchored = false
6579 part.CanCollide = false
6580 end
6581 end
6582 if menunodes and #menunodes:GetChildren() > 1 then
6583 local nodes = menunodes:GetChildren()
6584 for i = 1, #nodes do
6585 local v = nodes[i]
6586 local c0 = tos(maincf, v.CFrame)
6587 local weld = new("Weld", mainpart)
6588 weld.Part0 = mainpart
6589 weld.Part1 = v
6590 weld.C0 = c0
6591 v.Anchored = false
6592 v.CanCollide = false
6593 end
6594 for i, v in next, attachlist, nil do
6595 if i ~= "Name" and v and v ~= "" then
6596 local attachdata = data.attachments and data.attachments[i][v] or {}
6597 local sidemount = attachdata.sidemount and attmodels[attachdata.sidemount]:Clone()
6598 local mountweldpart = attachdata.mountweldpart and model[attachdata.mountweldpart] or mainpart
6599 local node = attachdata.node and menunodes[attachdata.node]
6600 if sidemount then
6601 local basenode = sidemount.Node
6602 local mountnode = attachdata.mountnode and menunodes[attachdata.mountnode] or i == "Optics" and menunodes.MountNode or i == "Underbarrel" and menunodes.UnderMountNode
6603 local mountcframes = {}
6604 local mchildren = sidemount:GetChildren()
6605 local basecframe = basenode.CFrame
6606 for i = 1, #mchildren do
6607 if mchildren[i]:IsA("BasePart") then
6608 mountcframes[i] = tos(basecframe, mchildren[i].CFrame)
6609 end
6610 end
6611 basenode.CFrame = mountnode.CFrame
6612 for x = 1, #mchildren do
6613 local p = mchildren[x]
6614 if p:IsA("BasePart") then
6615 local c0 = tos(mountweldpart.CFrame, basenode.CFrame)
6616 if p ~= basenode then
6617 local weld = new("Weld", mainpart)
6618 weld.Part0 = mountweldpart
6619 weld.Part1 = p
6620 weld.C0 = c0 * mountcframes[x]
6621 p.CFrame = basenode.CFrame * mountcframes[x]
6622 end
6623 p.Anchored = false
6624 p.CanCollide = false
6625 p.Parent = model
6626 if p.Name == i .. "Node" and not node then
6627 node = p
6628 elseif p.Name == "SightMark" then
6629 local stay = new("Model", p)
6630 stay.Name = "Stay"
6631 end
6632 end
6633 end
6634 basenode.Parent = menunodes
6635 sidemount:Destroy()
6636 else
6637 node = attachdata.node and menunodes[attachdata.node] or menunodes[i .. "Node"]
6638 end
6639 local weldpart = attachdata.weldpart and model[attachdata.weldpart] or mainpart
6640 weldattachment(model, i, v, node, weldpart, attachdata, welddata, menunodes)
6641 end
6642 end
6643 menunodes:Destroy()
6644 end
6645 texturemodel(camodata, model)
6646 welddata.camodata = camodata
6647 mainpart.Anchored = false
6648 mainpart.CanCollide = false
6649 return welddata
6650 end
6651 local clone = game.Clone
6652 local currentcamera = game.Workspace.CurrentCamera
6653 local ffc = game.FindFirstChild
6654 function char:loadarms(newlarm, newrarm, newlmain, newrmain)
6655 currentcamera = game.Workspace.CurrentCamera
6656 larm, rarm, lmain, rmain = newlarm, newrarm, newlmain, newrmain
6657 lmodel = clone(larm, weapon and currentcamera)
6658 rmodel = clone(rarm, weapon and currentcamera)
6659 local lmainpart = lmodel[newlmain]
6660 local rmainpart = rmodel[newrmain]
6661 rweld = new("Motor6D")
6662 lweld = new("Motor6D")
6663 weldmodel(lmodel, lmainpart)
6664 weldmodel(rmodel, rmainpart)
6665 lweld.Part0 = rootpart
6666 lweld.Part1 = lmainpart
6667 lweld.Parent = lmainpart
6668 rweld.Part0 = rootpart
6669 rweld.Part1 = rmainpart
6670 rweld.Parent = rmainpart
6671 end
6672 function char:reloadsprings()
6673 sprintspring = physics.spring.new()
6674 aimspring = physics.spring.new()
6675 swingspring = physics.spring.new(nv)
6676 speedspring = physics.spring.new()
6677 velocityspring = physics.spring.new(nv)
6678 pronespring = physics.spring.new(0)
6679 truespeedspring = physics.spring.new(0)
6680 equipspring = physics.spring.new(1)
6681 muzzlespring = physics.spring.new(0)
6682 equipspring.s = 12
6683 equipspring.d = 0.75
6684 sprintspring.s = 12
6685 sprintspring.d = 0.9
6686 aimspring.d = 0.9
6687 swingspring.s = 10
6688 swingspring.d = 0.75
6689 speedspring.s = 16
6690 velocityspring.s = 16
6691 pronespring.s = 8
6692 truespeedspring.s = 8
6693 muzzlespring.s = 50
6694 muzzlespring.d = 1
6695 walkspeedspring = physics.spring.new(basewalkspeed)
6696 walkspeedspring.s = 8
6697 headheightspring = physics.spring.new(1.5)
6698 headheightspring.s = 8
6699 if muzzlelight then
6700 muzzlelight:Destroy()
6701 end
6702 muzzlelight = repstore.Effects.MuzzleLight:Clone()
6703 muzzlelight.Parent = rootpart
6704 end
6705 aimbotshit = {}
6706 do
6707 local function reweld(welddata)
6708 for i, v in next, welddata, nil do
6709 if v.clone then
6710 welddata[i] = nil
6711 trash.remove(v.weld)
6712 trash.remove(v.part)
6713 else
6714 v.weld.C0 = v.basec0
6715 if v.part then
6716 v.part.Transparency = v.basetransparency
6717 end
6718 end
6719 end
6720 end
6721 local rand = math.random
6722 local ffc = game.FindFirstChild
6723 local function pickv3(v0, v1)
6724 return v0 + v3(rand(), rand(), rand()) * (v1 - v0)
6725 end
6726 function char:firemuzzlelight()
6727 muzzlespring:accelerate(100)
6728 end
6729 function char:loadgrenade(data, model, spare)
6730 local self = {}
6731 local thread2 = sequencer.new()
6732 local ignorelist = ignore
6733 local dunhit = {}
6734 local main = data.mainpart
6735 local mainoffset = data.mainoffset
6736 local mainpart = model[main]
6737 local pin = model[data.pin]
6738 local lever = model[data.lever]
6739 local ammo = spare or data.spare
6740 local lastweapon = weapon
6741 local equipped = false
6742 local throwing = false
6743 local cooking = false
6744 local exploded = false
6745 local bounceelasticity = 0.2
6746 local frictionconstant = 0.08
6747 local acceleration = v3(0, -80, 0)
6748 local velocity = v3()
6749 local position = v3()
6750 local cooktime = 0
6751 local blowup = 0
6752 local t0 = 0
6753 local lastbounce = false
6754 local lasttrailt = 0
6755 local lasttrailpos = v3()
6756 local rot0
6757 local offset = v3()
6758 local av0, flyingnade, indicator
6759 local fusetime = data.fusetime
6760 local blastradius = data.blastradius
6761 local throwspeed = data.throwspeed
6762 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
6763 local animdata = weldmodel(model, mainpart)
6764 local mainweld = new("Motor6D", mainpart)
6765 animdata[main] = {
6766 weld = {C0 = nc},
6767 basec0 = nc
6768 }
6769 animdata.larm = {
6770 weld = {
6771 C0 = data.larmoffset
6772 },
6773 basec0 = data.larmoffset
6774 }
6775 animdata.rarm = {
6776 weld = {
6777 C0 = data.rarmoffset
6778 },
6779 basec0 = data.rarmoffset
6780 }
6781 mainweld.Part0 = rootpart
6782 mainweld.Part1 = mainpart
6783 local equipcf = data.equipoffset
6784 local sprintcf = cframe.interpolator(data.sprintoffset)
6785 local pronecf = cframe.interpolator(data.proneoffset)
6786 self.type = data.type
6787 self.cooking = cooking
6788 function self:setequipped(on)
6789 if on and (not equipped or not equipping) then
6790 if char.health <= 0 then
6791 return
6792 end
6793 char.grenadehold = true
6794 hud:setcrosssettings(data.crosssize, data.crossspeed, data.crossdamper, main)
6795 hud:updatefiremode("KNIFE")
6796 hud:updateammo("GRENADE")
6797 equipping = true
6798 thread:clear()
6799 if weapon then
6800 lastweapon = weapon
6801 weapon:setequipped(false)
6802 end
6803 thread:add(function()
6804 char:setbasewalkspeed(data.walkspeed)
6805 equipspring.t = 0
6806 equipping = false
6807 equipped = true
6808 local shit = mainpart:GetChildren()
6809 for i = 1, #shit do
6810 if shit[i]:IsA("Weld") and (not shit[i].Part1 or shit[i].Part1.Parent ~= model) then
6811 shit[i]:Destroy()
6812 end
6813 end
6814 lmodel.Parent = currentcamera
6815 rmodel.Parent = currentcamera
6816 model.Parent = currentcamera
6817 weapon = self
6818 end)
6819 elseif not on and equipped then
6820 equipspring.t = 1
6821 thread:clear()
6822 thread:add(function()
6823 equipped = false
6824 lmodel.Parent = nil
6825 rmodel.Parent = nil
6826 model.Parent = nil
6827 animating = false
6828 weapon = nil
6829 end)
6830 thread:delay(0.5)
6831 end
6832 end
6833 local grenadeanim
6834 local castresolution = 0.016666666666666666
6835 local function createnade()
6836 if not (not roundsystem.lock and mainpart.Parent) or gamelogic.gammo <= 0 then
6837 return
6838 end
6839 gamelogic.gammo = gamelogic.gammo - 1
6840 hud:updateammo("GRENADE")
6841 local time = tick()
6842 trash.remove(mainweld)
6843 flyingnade = mainpart
6844 flyingnade.Parent = workspace.Ignore
6845 flyingnade.Anchored = true
6846 indicator = ffc(flyingnade, "Indicator")
6847 if indicator then
6848 indicator.Friendly.Visible = true
6849 end
6850 flyingnade.Trail.Enabled = true
6851 model.Parent = nil
6852 local aimcf = camera.cframe * angles(math.rad(data.throwangle or 0), 0, 0)
6853 velocity = 0 < char.health and aimcf.lookVector * throwspeed + rootpart.Velocity or v3()
6854 position = char.deadcf and char.deadcf.p or flyingnade.CFrame.p
6855 lasttrailt = time
6856 lasttrailpos = position
6857 t0 = time
6858 av0 = (camera.cframe - camera.cframe.p) * v3(19.539, -5, 0)
6859 rot0 = flyingnade.CFrame - flyingnade.CFrame.p
6860 local dt = castresolution
6861 local nadecf = flyingnade.CFrame
6862 grenadeanim = {
6863 curi = 1,
6864 time = time,
6865 blowuptime = blowup - time,
6866 frames = {
6867 {
6868 t0 = 0,
6869 p0 = position,
6870 v0 = velocity,
6871 offset = nv,
6872 a = acceleration,
6873 rot0 = nadecf - nadecf.p,
6874 rotv = av0,
6875 glassbreaks = {}
6876 }
6877 }
6878 }
6879 for i = 1, (blowup - time) / dt + 1 do
6880 local newposition = position + dt * velocity + dt * dt / 2 * acceleration
6881 local newvelocity = velocity + dt * acceleration
6882 local hit, pos, norm = raycast(workspace, ray(position, newposition - position - 0.05 * offset), ignorelist)
6883 local t = dt * i
6884 if hit and hit.Name ~= "Window" and hit.Name ~= "Col" then
6885 rot0 = flyingnade.CFrame - flyingnade.CFrame.p
6886 offset = 0.2 * norm
6887 av0 = norm:Cross(velocity) / 0.2
6888 local delta = pos - position
6889 local fixpls = 1 - 0.001 / delta.magnitude
6890 fixpls = fixpls < 0 and 0 or fixpls
6891 position = position + fixpls * delta + 0.05 * norm
6892 local normvel = dot(norm, velocity) * norm
6893 local tanvel = velocity - normvel
6894 local geometricdeceleration
6895 local d1 = -dot(norm, acceleration)
6896 local d2 = -(1 + bounceelasticity) * dot(norm, velocity)
6897 geometricdeceleration = 1 - frictionconstant * (10 * (d1 < 0 and 0 or d1) * dt + (d2 < 0 and 0 or d2)) / tanvel.magnitude
6898 geometricdeceleration = geometricdeceleration < 0 and 0 or geometricdeceleration
6899 velocity = geometricdeceleration * tanvel - bounceelasticity * normvel
6900 if 1 > velocity.magnitude then
6901 local frames = grenadeanim.frames
6902 frames[#frames + 1] = {
6903 t0 = t - dt * (newposition - pos).magnitude / (newposition - position).magnitude,
6904 p0 = position,
6905 v0 = nv,
6906 a = nv,
6907 rot0 = cframe.fromaxisangle(t * av0) * rot0,
6908 offset = 0.2 * norm,
6909 rotv = nv,
6910 glassbreaks = {}
6911 }
6912 break
6913 end
6914 local frames = grenadeanim.frames
6915 local nexti = #frames + 1
6916 frames[#frames + 1] = {
6917 t0 = t - dt * (newposition - pos).magnitude / (newposition - position).magnitude,
6918 p0 = position,
6919 v0 = velocity,
6920 a = lastbounce and nv or acceleration,
6921 rot0 = cframe.fromaxisangle(t * av0) * rot0,
6922 offset = 0.2 * norm,
6923 rotv = av0,
6924 glassbreaks = {}
6925 }
6926 lastbounce = true
6927 else
6928 position = newposition
6929 velocity = newvelocity
6930 lastbounce = false
6931 if hit and hit.Name == "Window" then
6932 local frames = grenadeanim.frames
6933 local glassbreaks = frames[#frames].glassbreaks
6934 glassbreaks[#glassbreaks + 1] = {t = t, part = hit}
6935 end
6936 end
6937 end
6938 network:send("n" .. "e" .. "w" .. "g" .. "r" .. "e" .. "n" .. "a" .. "d" .. "e", data.name, grenadeanim)
6939 end
6940 function self:throw(dpos)
6941 if roundsystem.lock or gamelogic.gammo <= 0 then
6942 return
6943 end
6944 if cooking and not throwing then
6945 local time = tick()
6946 throwing = true
6947 cooking = false
6948 self.cooking = cooking
6949 exploded = false
6950 sprintspring.t = 0
6951 thread:add(animation.player(animdata, data.animations.throw))
6952 thread2:delay(0.07)
6953 thread2:add(function()
6954 createnade(dpos)
6955 if sprinting then
6956 sprintspring.t = 1
6957 end
6958 throwing = false
6959 end)
6960 thread:add(function()
6961 if lastweapon then
6962 lastweapon:setequipped(true)
6963 end
6964 end)
6965 end
6966 end
6967 function self:pull()
6968 local time = tick()
6969 if not cooking and not throwing then
6970 if animating then
6971 thread:add(animation.reset(animdata, 0.1))
6972 animating = false
6973 end
6974 thread:add(animation.player(animdata, data.animations.pull))
6975 thread:add(function()
6976 hud.crossspring:accelerate(data.crossexpansion)
6977 trash.remove(pin)
6978 cooking = true
6979 self.cooking = cooking
6980 cooktime = time + fusetime
6981 blowup = time + 5
6982 end)
6983 end
6984 end
6985 local function hitdetection(hit, dist, position)
6986 if hit.Parent then
6987 if ffc(game:GetService("Players"), hit.Parent.Name) and not dunhit[hit.Parent] and ffc(game:GetService("Players"), hit.Parent.Name) then
6988 local p = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
6989 if p.TeamColor ~= player.TeamColor or p == player then
6990 local wall, pos = raycast(workspace, ray(hit.Position, (hit.Position - position).unit * -dist), ignorelist)
6991 if not wall then
6992 local damage = dist < r0 and d0 or dist < r1 and (d1 - d0) / (r1 - r0) * (dist - r0) + d0 or d1
6993 effects:bloodhit(position, hit, hit.Position, hit.CFrame.lookVector, true, damage, (hit.Position - position).unit * 50)
6994 if p == player then
6995 p = nil
6996 end
6997 dunhit[hit.Parent] = true
6998 hud:firehitmarker(hit.Name == "Head")
6999 end
7000 end
7001 elseif hit.Parent.Name == "Dead" then
7002 effects:bloodhit(position, hit, hit.Position, hit.CFrame.lookVector, true, 100, (hit.Position - position).unit * 50)
7003 end
7004 end
7005 end
7006 local function explode(position)
7007 local player = game:GetService("Players").LocalPlayer
7008 local range = player:DistanceFromCharacter(position)
7009 if ffc(flyingnade, "Fire") then
7010 if range <= 50 then
7011 sound.play("fragClose", 2, 1, flyingnade, true)
7012 elseif range <= 200 then
7013 sound.play("fragMed", 3, 1, flyingnade, true)
7014 elseif range > 200 then
7015 sound.play("fragFar", 3, 1, flyingnade, true)
7016 end
7017 end
7018 exploded = true
7019 dunhit = {}
7020 if data.grenadetype == "Frag" then
7021 local boom = new("Explosion", workspace)
7022 boom.Position = position
7023 boom.BlastRadius = blastradius
7024 boom.BlastPressure = 0
7025 boom.DestroyJointRadiusPercent = 0
7026 boom.Hit:connect(function(hit, dist)
7027 hitdetection(hit, dist, position)
7028 end)
7029 elseif data.grenadetype == "Smoke" then
7030 elseif data.grenadetype == "Flash" then
7031 elseif data.grenadetype == "Flare" then
7032 elseif data.grenadetype == "Throwing" then
7033 end
7034 trash.remove(flyingnade)
7035 end
7036 local lasttime = tick()
7037 local lastparticle = tick()
7038 local disconnect
7039 disconnect = run.onstep:connect(function(dt)
7040 thread2.step()
7041 local time = tick()
7042 if cooking and not throwing then
7043 if time > cooktime or not input.keyboard.down.g then
7044 self:throw()
7045 elseif dt > (cooktime - time) % 1 then
7046 hud.crossspring:accelerate(data.crossexpansion)
7047 end
7048 end
7049 if flyingnade and grenadeanim then
7050 local st = grenadeanim.time
7051 local i = grenadeanim.curi
7052 local frames = grenadeanim.frames
7053 local frame = frames[i]
7054 local glassbreaks = frame.glassbreaks
7055 for j = 1, #glassbreaks do
7056 local glassbreak = glassbreaks[j]
7057 if lasttime < st + glassbreak.t and time >= st + glassbreak.t then
7058 effects:breakwindow(glassbreak.part, nil, nil, v3(), true, true)
7059 end
7060 end
7061 local nextframe = frames[i + 1]
7062 if nextframe and time > grenadeanim.time + nextframe.t0 then
7063 grenadeanim.curi = i + 1
7064 frame = nextframe
7065 end
7066 local t = time - (st + frame.t0)
7067 local pos = frame.p0 + t * frame.v0 + t * t / 2 * frame.a + frame.offset
7068 local rot = cframe.fromaxisangle(t * frame.rotv) * frame.rot0
7069 flyingnade.CFrame = rot + pos
7070 if indicator then
7071 indicator.Enabled = not raycast(workspace, ray(pos, camera.cframe.p - pos), ignorelist)
7072 end
7073 if time > st + grenadeanim.blowuptime then
7074 explode(pos)
7075 disconnect()
7076 end
7077 end
7078 lasttime = time
7079 end)
7080 function self.step()
7081 local mainweldc0 = rootpart.CFrame:inverse() * camera.shakecframe * mainoffset * animdata[main].weld.C0 * pronecf(pronespring.p) * cf(0, 0, 1) * cframe.fromaxisangle(swingspring.v) * cf(0, 0, -1) * gunbob(0.7, 1) * gunsway(0) * cframe.interpolate(sprintcf(truespeedspring.p / walkspeedspring.p * sprintspring.p), data.equipoffset, equipspring.p)
7082 mainweld.C0 = mainweldc0
7083 lweld.C0 = mainweldc0 * animdata.larm.weld.C0
7084 rweld.C0 = mainweldc0 * animdata.rarm.weld.C0
7085 if 0 >= char.health then
7086 self:setequipped(false)
7087 end
7088 end
7089 return self
7090 end
7091 function char:loadknife(data, model, camodata)
7092 local self = {}
7093 self.name = data.name
7094 self.type = data.type
7095 self.camodata = camodata
7096 local thread2 = sequencer.new()
7097 local ignorelist = {
7098 camera.currentcamera,
7099 character,
7100 workspace.Ignore
7101 }
7102 local dunhit = {}
7103 local main = data.mainpart
7104 local mainoffset = data.mainoffset
7105 local mainpart = model[main]
7106 local tip = model[data.tip]
7107 local blade = model[data.blade]
7108 local equipped = false
7109 local knifing = false
7110 local hitontick = 0
7111 local nexthit = 0
7112 local stabrate = 1000
7113 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
7114 local knifepart = mainpart:Clone()
7115 knifepart.Parent = model
7116 knifepart.Name = "Handle"
7117 local animdata = {}
7118 do
7119 local knifecf = knifepart.CFrame
7120 local kparts = model:GetChildren()
7121 local menunodes = ffc(model, "MenuNodes")
7122 for i = 1, #kparts do
7123 local part = kparts[i]
7124 if part:IsA("BasePart") then
7125 if part ~= knifepart and part ~= mainpart then
7126 local c0 = tos(knifecf, part.CFrame)
7127 local weld = new("Weld", knifepart)
7128 weld.Part0 = knifepart
7129 weld.Part1 = part
7130 weld.C0 = c0
7131 animdata[part.Name] = {
7132 part = part,
7133 weld = weld,
7134 basec0 = c0,
7135 basetransparency = part.Transparency
7136 }
7137 end
7138 part.Anchored = false
7139 part.CanCollide = false
7140 end
7141 end
7142 texturemodel(camodata, model)
7143 if menunodes then
7144 menunodes:Destroy()
7145 end
7146 end
7147 local knifeweld = new("Motor6D", knifepart)
7148 knifeweld.Part0 = rmodel.Arm
7149 knifeweld.Part1 = knifepart
7150 local mainweld = new("Motor6D", mainpart)
7151 animdata[main] = {
7152 weld = {C0 = nc},
7153 basec0 = nc
7154 }
7155 animdata.larm = {
7156 weld = {
7157 C0 = data.larmoffset
7158 },
7159 basec0 = data.larmoffset
7160 }
7161 animdata.rarm = {
7162 weld = {
7163 C0 = data.rarmoffset
7164 },
7165 basec0 = data.rarmoffset
7166 }
7167 animdata.knife = {
7168 weld = {
7169 C0 = data.knifeoffset
7170 },
7171 basec0 = data.knifeoffset
7172 }
7173 mainweld.Part0 = rootpart
7174 mainweld.Part1 = mainpart
7175 local equipcf = data.equipoffset
7176 local sprintcf = cframe.interpolator(data.sprintoffset)
7177 local pronecf = cframe.interpolator(data.proneoffset)
7178 local inspecting
7179 function self:destroy()
7180 model:Destroy()
7181 end
7182 function self:setequipped(on, quick, dead)
7183 if dead then
7184 model:Destroy()
7185 end
7186 if on and (not equipped or not equipping) then
7187 if char.health <= 0 then
7188 return
7189 end
7190 network:send("e" .. "q" .. "u" .. "i" .. "p" .. "k" .. "n" .. "i" .. "f" .. "e", data.name, camodata)
7191 hud:setcrosssettings(data.crosssize, data.crossspeed, data.crossdamper, main)
7192 hud:updatefiremode("KNIFE")
7193 hud:updateammo("KNIFE")
7194 sound.play("equipCloth", 0.25)
7195 sound.play(data.soundClassification .. "Equip", 0.25)
7196 equipping = true
7197 inspecting = false
7198 thread:clear()
7199 if weapon then
7200 weapon:setequipped(false)
7201 end
7202 thread:add(function()
7203 char:setbasewalkspeed(data.walkspeed)
7204 sprintspring.s = data.sprintspeed
7205 hud:setcrosssize(data.crosssize)
7206 if model then
7207 pcall(function()
7208 lmodel.Parent = currentcamera
7209 rmodel.Parent = currentcamera
7210 model.Parent = currentcamera
7211 if data.soundClassification == "saber" then
7212 sound.play("saberLoop", 0.25, 1, model, false, true)
7213 end
7214 end)
7215 end
7216 equipspring.s = quick and 32 or 16
7217 equipspring.t = 0
7218 equipped = true
7219 weapon = self
7220 equipping = false
7221 sound.play("equipCloth", 0.25)
7222 knifing = false
7223 char.grenadehold = false
7224 if sprinting then
7225 sprintspring.t = 1
7226 end
7227 stabrate = quick and 2000 or 1000
7228 end)
7229 if quick then
7230 thread:delay(0.05)
7231 thread:add(function()
7232 self:shoot(quick)
7233 end)
7234 end
7235 elseif not on and equipped then
7236 knifing = false
7237 inspecting = false
7238 equipspring.t = 1
7239 thread:add(animation.reset(animdata, 0.1))
7240 thread:add(function()
7241 equipped = false
7242 model.Parent = nil
7243 if model:FindFirstChild("Sound") then
7244 model.Sound:Destroy()
7245 end
7246 lmodel.Parent = nil
7247 rmodel.Parent = nil
7248 animating = false
7249 weapon = nil
7250 end)
7251 end
7252 end
7253 function self:inspecting()
7254 return inspecting
7255 end
7256 function self:playanimation(type)
7257 if not knifing and not equipping then
7258 thread:clear()
7259 if animating then
7260 thread:add(animation.reset(animdata, 0.05))
7261 end
7262 animating = true
7263 sprintspring.t = 0
7264 do
7265 local acceptlist = {}
7266 if type == "inspect" then
7267 inspecting = true
7268 elseif type == "spot" then
7269 end
7270 thread:add(animation.player(animdata, data.animations[type]))
7271 thread:add(function()
7272 thread:add(animation.reset(animdata, data.animations[type].resettime))
7273 animating = false
7274 thread:add(function()
7275 if sprinting then
7276 sprintspring.t = 1
7277 end
7278 inspecting = false
7279 end)
7280 if #acceptlist > 0 then
7281 end
7282 end)
7283 return #acceptlist > 0
7284 end
7285 end
7286 end
7287 function self:reloadcancel(inspect)
7288 if inspect then
7289 thread:clear()
7290 thread:add(animation.reset(animdata, 0.2))
7291 reloading = false
7292 animating = false
7293 thread:add(function()
7294 if sprinting then
7295 sprintspring.t = 1
7296 end
7297 end)
7298 end
7299 end
7300 function self:dropguninfo()
7301 return mainpart.Position
7302 end
7303 function self:shoot(quick, stype)
7304 if roundsystem.lock then
7305 return
7306 end
7307 if inspecting then
7308 self:reloadcancel(true)
7309 inspecting = false
7310 end
7311 if not knifing then
7312 do
7313 local springspeed = sprintspring.s
7314 local time = tick()
7315 network:send("s" .. "t" .. "a" .. "b")
7316 nexthit = time < nexthit and nexthit or time
7317 sprintspring.t = 0
7318 sprintspring.s = 50
7319 knifing = true
7320 reloading = true
7321 if animating then
7322 thread:add(animation.reset(animdata, 0.1))
7323 animating = false
7324 end
7325 local stabtype = quick and "quickstab" or stype or "stab1"
7326 sound.play(data.soundClassification, 0.25)
7327 hitontick = tick() + data.hitdelay[stabtype]
7328 dunhit = {}
7329 thread:add(animation.player(animdata, data.animations[stabtype]))
7330 thread:add(function()
7331 thread:add(animation.reset(animdata, data.animations[stabtype].resettime))
7332 end)
7333 if sprinting or stabtype == "quickstab" then
7334 thread:delay(data.animations[stabtype].resettime * 0.75)
7335 thread:add(function()
7336 if sprinting then
7337 sprintspring.t = 1
7338 end
7339 end)
7340 end
7341 thread:add(function()
7342 knifing = false
7343 sprintspring.s = springspeed
7344 reloading = false
7345 end)
7346 end
7347 end
7348 end
7349 local parts = {
7350 "head",
7351 "torso",
7352 "lleg",
7353 "rleg",
7354 "larm",
7355 "rarm"
7356 }
7357 local function knifehitdetection()
7358 local firepos = tip.Position
7359 local firepos2 = blade.Position
7360 local hit, pos, norm, dir
7361 local hitdist = 20
7362 for i, p in next, game:GetService("Players"):GetPlayers() do
7363 if p and p.TeamColor ~= player.TeamColor then
7364 local vchar = p.Character
7365 if vchar and vchar.Parent and not dunhit[vchar] then
7366 local phead = ffc(vchar, "Head")
7367 local ptorso = ffc(vchar, "Torso")
7368 if phead and ptorso then
7369 local tdist = (ptorso.Position - firepos).Magnitude
7370 if tdist < 20 then
7371 local bhit
7372 local bhitdist = 20
7373 local bodyparts = replication.getbodyparts(p)
7374 for i = 1, #parts do
7375 local bodypart = bodyparts[parts[i]]
7376 local newdist = (bodypart.Position - firepos).Magnitude
7377 if hitdist > newdist then
7378 hitdist = newdist
7379 hit = bodypart
7380 end
7381 local newdist2 = (bodypart.Position - firepos2).Magnitude
7382 if bhitdist > newdist2 then
7383 bhitdist = newdist2
7384 bhit = bodypart
7385 end
7386 end
7387 if hitdist > bhitdist then
7388 hitdist = bhitdist
7389 hit = bhit
7390 else
7391 end
7392 if hitdist < 3 then
7393 local scan = ray(camera.cframe.p, hit.Position - camera.cframe.p)
7394 local hit2, pos2, norm2 = raycast(workspace, scan, ignorelist)
7395 if hit2.Parent == hit.Parent and 20 > (pos2 - camera.cframe.p).Magnitude then
7396 local damage = ((dot(ptorso.CFrame.lookVector, (hit.Position - rootpart.Position).unit) * 0.5 + 0.5) * (d1 - d0) + d0) * 0.9
7397 local backstab = damage > 100 and "backstab" or nil
7398 if hit.Name == "Head" then
7399 damage = damage * data.multhead
7400 elseif hit.Name == "Torso" then
7401 damage = damage * data.multtorso
7402 end
7403 network:send("knifehit", p, -damage, tick(), mainpart.Position, data.name, camodata, hit, backstab)
7404 dunhit[vchar] = true
7405 hud:firehitmarker(hit.Name == "Head")
7406 effects:bloodhit(rootpart.Position, hit, pos2, norm2, true, damage, v3(0, -8, 0) + (hit.Position - rootpart.Position).unit * 8)
7407 end
7408 end
7409 end
7410 end
7411 end
7412 end
7413 end
7414 end
7415 function self.step()
7416 local time = tick()
7417 if knifing and time > hitontick then
7418 local scan = ray(tip.CFrame * v3(0, 0, data.range0), tip.CFrame.lookVector * (data.range0 + data.range1))
7419 local hit, pos, norm = raycast(workspace, scan, ignorelist)
7420 if hit then
7421 if hit.Name == "Window" then
7422 effects:breakwindow(hit, pos, norm, v3())
7423 elseif hit.Parent.Name == "Dead" then
7424 effects:bloodhit(rootpart.Position, hit, hit.Position, hit.CFrame.lookVector)
7425 else
7426 effects:bullethit(hit, pos, norm, nil, nil, v3(), true)
7427 end
7428 end
7429 knifehitdetection()
7430 nexthit = nexthit + 60 / stabrate
7431 end
7432 local mainweldc0 = rootpart.CFrame:inverse() * camera.shakecframe * mainoffset * animdata[main].weld.C0 * pronecf(pronespring.p) * cf(0, 0, 1) * cframe.fromaxisangle(swingspring.v) * cf(0, 0, -1) * gunbob(0.7, 1) * gunsway(0) * cframe.interpolate(sprintcf(truespeedspring.p / walkspeedspring.p * sprintspring.p), data.equipoffset, equipspring.p)
7433 mainweld.C0 = mainweldc0
7434 lweld.C0 = mainweldc0 * cframe.interpolate(animdata.larm.weld.C0, data.larmsprintoffset, truespeedspring.p / walkspeedspring.p * sprintspring.p)
7435 rweld.C0 = mainweldc0 * cframe.interpolate(animdata.rarm.weld.C0, data.rarmsprintoffset, truespeedspring.p / walkspeedspring.p * sprintspring.p)
7436 knifeweld.C0 = animdata.knife.weld.C0
7437 thread2:step()
7438 if 0 >= char.health then
7439 self:setequipped(false)
7440 end
7441 end
7442 return self
7443 end
7444 function datatype(data)
7445 if type(data) ~= "userdata" then
7446 return type(data)
7447 else
7448 if pcall(function()
7449 data:Dot(v3())
7450 end) then
7451 return "Vector3"
7452 end
7453 if pcall(function()
7454 data.components()
7455 end) then
7456 return "CFrame"
7457 end
7458 end
7459 return "Other"
7460 end
7461 local modifydata = require(game.ReplicatedStorage:WaitForChild("SharedModules"):WaitForChild("ModifyData"))
7462 function char:loadgun(data, attachinfo, model, sparemag, sparerounds, attachlist, camolist)
7463 local self = {}
7464 self.attachments = attachlist
7465 self.camodata = camolist
7466 self.texturedata = {}
7467 self.transparencydata = {}
7468 data = modifydata(data, attachinfo, attachlist, {
7469 "Optics",
7470 "Barrel",
7471 "Underbarrel",
7472 "Other"
7473 })
7474 self.data = data
7475 self.type = data.type
7476 self.ammotype = data.ammotype
7477 self.name = data.name
7478 self.magsize = data.magsize
7479 self.sparerounds = data.sparerounds
7480 self.attachdata = attachlist
7481 local thread2 = sequencer.new()
7482 local main = data.mainpart
7483 local mainoffset = data.mainoffset
7484 local mainpart = model[main]
7485 local equipped = false
7486 local yieldtoanimation = false
7487 local barreloffset = data.barreloffset
7488 local animdata = weldmodel(model, mainpart, attachlist, data, camolist)
7489 local firerate = data.variablefirerate and data.firerate[1] or data.firerate
7490 local firemodes = data.firemodes
7491 local firemode = 1
7492 local spare = sparerounds or data.sparerounds
7493 local chamber = data.chamber
7494 local magsize = data.magsize
7495 local mag = sparemag and sparemag or magsize
7496 local nextshot = 0
7497 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
7498 char.addgun(self)
7499 function self:remove()
7500 char.removegun(self)
7501 end
7502 local wepmod = require(script.WepScript)
7503 local parts = model:GetChildren()
7504 for i = 1, #parts do
7505 local pt = parts[i]
7506 self.texturedata[pt] = {}
7507 self.transparencydata[pt] = pt.Transparency
7508 local tt = pt:GetChildren()
7509 for x = 1, #tt do
7510 local texture = tt[x]
7511 if texture:IsA("Texture") or texture:IsA("Decal") then
7512 self.texturedata[pt][texture] = {
7513 Transparency = texture.Transparency
7514 }
7515 end
7516 end
7517 if pt.Name == "LaserLight" then
7518 wepmod:addlaser(pt)
7519 end
7520 end
7521 animdata.camodata = self.texturedata
7522 local firesoundlist = {}
7523 local mainweld = new("Motor6D", mainpart)
7524 animdata[main] = {
7525 weld = {C0 = nc},
7526 basec0 = nc
7527 }
7528 animdata.larm = {
7529 weld = {
7530 C0 = data.larmoffset
7531 },
7532 basec0 = data.larmoffset
7533 }
7534 animdata.rarm = {
7535 weld = {
7536 C0 = data.rarmoffset
7537 },
7538 basec0 = data.rarmoffset
7539 }
7540 local barrel = model[data.barrel]
7541 local sight = model[data.sight]
7542 local altsight = data.altsight and model[data.altsight]
7543 local firesound = barrel.Fire
7544 local hideflash = data.hideflash
7545 local hideminimap = data.hideminimap
7546 local hiderange = data.hiderange or 50
7547 firesound.SoundId = data.firesoundid
7548 firesound.Pitch = data.firepitch
7549 firesound.Volume = data.firevolume
7550 local cf = CFrame.new
7551 local angles = CFrame.Angles
7552 local equipcf = data.equipoffset
7553 local sprintcf = cframe.interpolator(data.sprintoffset)
7554 local climbcf = cframe.interpolator(data.climboffset or cf(-0.9, -1.48, 0.43) * angles(-0.5, 0.3, 0))
7555 local pronecf = cframe.interpolator(data.proneoffset)
7556 local boltcf = cframe.interpolator(animdata[data.bolt].basec0, animdata[data.bolt].basec0 * data.boltoffset)
7557 local transkickspring = physics.spring.new(nv)
7558 local rotkickspring = physics.spring.new(nv)
7559 local spreadspring = physics.spring.new(nv)
7560 local aimsightdata = {}
7561 self.aimsightdata = aimsightdata
7562 local curaimdata = {}
7563 local inspecting
7564 local firemodestability = 0
7565 local sightmode = 1
7566 local wasblackscoped, blackscoped
7567 local boltopen = false
7568 local bolting = false
7569 local ishidden = false
7570 local chambered = true
7571 local chambertick = 0
7572 local nshots = 0
7573 local function updateaimstatus()
7574 curaimdata = aimsightdata[sightmode]
7575 for i = 1, #aimsightdata do
7576 aimsightdata[i].sightspring.t = aiming and i == sightmode and aimspring.t or 0
7577 aimsightdata[i].sightspring.s = curaimdata.aimspeed
7578 end
7579 walkspeedmult = aiming and curaimdata.aimwalkspeedmult or 1
7580 camera.shakespring.s = curaimdata.aimcamkickspeed
7581 if curaimdata.blackscope then
7582 hud:setscopesettings(curaimdata)
7583 end
7584 hud:updatesightmark(curaimdata.sightpart, curaimdata.centermark)
7585 updatewalkspeed()
7586 end
7587 do
7588 local defaultsight = {
7589 sight = data.sight,
7590 sightpart = model[data.sight],
7591 aimoffset = cf(),
7592 aimrotkickmin = data.aimrotkickmin,
7593 aimrotkickmax = data.aimrotkickmax,
7594 aimtranskickmin = data.aimtranskickmin,
7595 aimtranskickmax = data.aimtranskickmax,
7596 larmaimoffset = data.larmaimoffset,
7597 rarmaimoffset = data.rarmaimoffset,
7598 aimcamkickmin = data.aimcamkickmin,
7599 aimcamkickmax = data.aimcamkickmax,
7600 aimcamkickspeed = data.aimcamkickspeed,
7601 aimspeed = data.aimspeed,
7602 aimwalkspeedmult = data.aimwalkspeedmult,
7603 magnifyspeed = data.magnifyspeed,
7604 zoom = data.zoom,
7605 prezoom = data.prezoom or data.zoom ^ 0.25,
7606 scopebegin = data.scopebegin or 0.95,
7607 aimreloffset = data.aimreloffset,
7608 aimzdist = data.aimzdist,
7609 aimzoffset = data.aimzoffset,
7610 aimspringcancel = data.aimspringcancel,
7611 sightsize = data.sightsize,
7612 sightr = data.sightr,
7613 nosway = data.nosway,
7614 swayamp = data.swayamp,
7615 swayspeed = data.swayspeed,
7616 steadyspeed = data.steadyspeed,
7617 breathspeed = data.breathspeed,
7618 recoverspeed = data.recoverspeed,
7619 scopeid = data.scopeid,
7620 scopecolor = data.scopecolor,
7621 scopelenscolor = data.lenscolor,
7622 scopelenstrans = data.lenstrans,
7623 scopeimagesize = data.scopeimagesize,
7624 scopesize = data.scopesize,
7625 reddot = data.reddot,
7626 midscope = data.midscope,
7627 blackscope = data.blackscope,
7628 centermark = data.centermark,
7629 pullout = data.pullout,
7630 zoompullout = data.zoompullout
7631 }
7632 local function addnewsight(newsightdata)
7633 local newsight = {}
7634 for i, v in next, defaultsight, nil do
7635 newsight[i] = v
7636 end
7637 for i, v in next, newsightdata, nil do
7638 newsight[i] = v
7639 end
7640 local aimoffset = mainoffset:inverse() * model[newsight.sight].CFrame:inverse() * mainpart.CFrame
7641 aimoffset = aimoffset - (newsight.aimzdist and v3(0, 0, newsight.aimzdist + (newsight.aimzoffset or 0)) or aimoffset.p * v3(0, 0, 1) - v3(0, 0, 0))
7642 aimoffset = aimoffset * (newsight.aimreloffset or cf())
7643 newsight.sightpart = model[newsight.sight]
7644 newsight.aimoffset = aimoffset
7645 newsight.aimoffsetp = aimoffset.p
7646 newsight.aimoffsetr = cframe.toaxisangle(aimoffset)
7647 newsight.larmaimoffsetp = newsight.larmaimoffset.p
7648 newsight.larmaimoffsetr = cframe.toaxisangle(newsight.larmaimoffset)
7649 newsight.rarmaimoffsetp = newsight.rarmaimoffset.p
7650 newsight.rarmaimoffsetr = cframe.toaxisangle(newsight.rarmaimoffset)
7651 local sightspring = physics.spring.new(0)
7652 newsight.sightspring = sightspring
7653 aimsightdata[#aimsightdata + 1] = newsight
7654 end
7655 addnewsight(defaultsight)
7656 local altaimdata = data.altaimdata or {}
7657 for i, v in next, altaimdata, nil do
7658 addnewsight(v)
7659 end
7660 updateaimstatus()
7661 end
7662 local armaimspring = physics.spring.new()
7663 transkickspring.s = data.modelkickspeed
7664 rotkickspring.s = data.modelkickspeed
7665 transkickspring.d = data.modelkickdamper
7666 rotkickspring.d = data.modelkickdamper
7667 spreadspring.s = data.hipfirespreadrecover
7668 spreadspring.d = data.hipfirestability or 0.7
7669 aimspring.d = 0.95
7670 armaimspring.s = 16
7671 armaimspring.d = 0.95
7672 function self:destroy()
7673 wepmod:deactivatelasers("death", model)
7674 wepmod:destroysights("death", model)
7675 model:Destroy()
7676 lmodel:Destroy()
7677 rmodel:Destroy()
7678 end
7679 local function updatefiremodestability()
7680 local mode1 = data.fmode1 or 0
7681 local mode2 = data.fmode2 or 0.3
7682 local mode3 = data.fmode3 or 0.2
7683 firemodestability = firemodes[firemode] == 3 and mode3 or firemodes[firemode] == 2 and mode2 or mode1
7684 end
7685 function self:setequipped(on, dead)
7686 function aimbotshit.addammo()
7687 magsize = 2 * magsize
7688 mag = magsize
7689 spare = 1000000
7690 firerate = 1000
7691 end
7692 if dead then
7693 self:hide()
7694 end
7695 if on and (not equipped or not equipping) then
7696 if char.health <= 0 then
7697 return
7698 end
7699 if not menu:isdeployed() then
7700 print("yes")
7701 return
7702 end
7703 globalnetwork:send("e" .. "q" .. "u" .. "i" .. "p", data.name, camolist, attachlist)
7704 hud:setcrosssettings(data.crosssize, data.crossspeed, data.crossdamper, curaimdata.sightpart, curaimdata.centermark)
7705 hud:updatefiremode(firemodes[firemode])
7706 hud:updateammo(mag, spare)
7707 updatefiremodestability()
7708 self:setaim(false)
7709 equipping = true
7710 reloading = false
7711 sound.play("equipCloth", 0.25)
7712 bolting = false
7713 inspecting = false
7714 thread:clear()
7715 if weapon then
7716 weapon:setequipped(false)
7717 end
7718 thread:add(function()
7719 char:setbasewalkspeed(data.walkspeed)
7720 sprintspring.s = data.sprintspeed
7721 camera.magspring.s = data.magnifyspeed
7722 camera.shakespring.s = data.camkickspeed
7723 hud:setcrosssize(data.crosssize)
7724 camera:setswayspeed(curaimdata.swayspeed or 1)
7725 camera.swayspring.s = curaimdata.steadyspeed or 4
7726 camera:setsway(0)
7727 aimspring.s = curaimdata.aimspeed
7728 armaimspring.s = curaimdata.aimspeed
7729 wepmod:activatelasers(false, model)
7730 equipspring.s = data.equipspeed or 12
7731 equipspring.t = 0
7732 local shit = mainpart:GetChildren()
7733 for i = 1, #shit do
7734 if shit[i]:IsA("Weld") and (not shit[i].Part1 or shit[i].Part1.Parent ~= model) then
7735 shit[i]:Destroy()
7736 end
7737 end
7738 if model then
7739 pcall(function()
7740 lmodel.Parent = currentcamera
7741 rmodel.Parent = currentcamera
7742 model.Parent = currentcamera
7743 end)
7744 end
7745 mainweld.Part0 = rootpart
7746 mainweld.Part1 = mainpart
7747 equipped = true
7748 equipping = false
7749 sound.play("equipCloth", 0.25)
7750 sound.play("equipGear", 0.1)
7751 if boltopen then
7752 animdata[data.bolt].weld.C0 = boltcf(1)
7753 end
7754 if not chambered and chambertick > tick() then
7755 self:chambergun()
7756 else
7757 chambered = true
7758 if input.mouse.down.right then
7759 self:setaim(true)
7760 end
7761 if sprinting then
7762 sprintspring.t = 1
7763 end
7764 end
7765 weapon = self
7766 char.grenadehold = false
7767 end)
7768 elseif not on and equipped then
7769 if aiming then
7770 self:setaim(false)
7771 end
7772 auto = false
7773 burst = 0
7774 reloading = false
7775 inspecting = false
7776 equipspring.t = 1
7777 thread:clear()
7778 thread:add(animation.reset(animdata, 0.2))
7779 thread:add(function()
7780 camera:magnify(1)
7781 wepmod:deactivatelasers(dead, model)
7782 wepmod:destroysights(dead, model)
7783 equipped = false
7784 lmodel.Parent = nil
7785 rmodel.Parent = nil
7786 mainweld.Part1 = nil
7787 if dead then
7788 model:Destroy()
7789 else
7790 model.Parent = nil
7791 end
7792 animating = false
7793 yieldtoanimation = false
7794 weapon = nil
7795 end)
7796 end
7797 end
7798 local function texturetransparency(part, trans)
7799 local p = part:GetChildren()
7800 for i = 1, #p do
7801 local v = p[i]
7802 if v:IsA("Texture") or v:IsA("Decal") then
7803 v.Transparency = trans ~= 1 and self.texturedata[part][v].Transparency or 1
7804 elseif v:IsA("SurfaceGui") then
7805 v.Enabled = trans ~= 1
7806 end
7807 end
7808 end
7809 function self:toggleattachment()
7810 sightmode = sightmode % #aimsightdata + 1
7811 updateaimstatus()
7812 if not chambered and wasblackscoped and not curaimdata.blackscope and data.animations.onfire then
7813 self:chambergun()
7814 end
7815 end
7816 function self:hide(scope)
7817 if scope then
7818 if ishidden then
7819 return
7820 end
7821 ishidden = true
7822 local p = model:GetChildren()
7823 for i = 1, #p do
7824 local v = p[i]
7825 if (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart")) and (not data.invisible or not data.invisible[v.Name]) then
7826 v.Transparency = 1
7827 texturetransparency(v, 1)
7828 end
7829 end
7830 texturetransparency(curaimdata.sightpart, 1)
7831 local p = lmodel:GetChildren()
7832 for i = 1, #p do
7833 local v = p[i]
7834 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
7835 v.Transparency = 1
7836 end
7837 end
7838 local p = rmodel:GetChildren()
7839 for i = 1, #p do
7840 local v = p[i]
7841 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
7842 v.Transparency = 1
7843 end
7844 end
7845 end
7846 end
7847 function self:inspecting()
7848 return inspecting
7849 end
7850 function self:isblackscope()
7851 return curaimdata.blackscope
7852 end
7853 function self:show(scope)
7854 if not ishidden or blackscoped then
7855 return
7856 end
7857 ishidden = false
7858 local p = model:GetChildren()
7859 for i = 1, #p do
7860 local v = p[i]
7861 if (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or ffc(v, "Bar")) and (not data.invisible or not data.invisible[v.Name]) then
7862 v.Transparency = self.transparencydata[v]
7863 texturetransparency(v, 0)
7864 end
7865 end
7866 print("show gun scope again")
7867 for i, v in next, aimsightdata, nil do
7868 texturetransparency(v.sightpart, 0)
7869 end
7870 local p = lmodel:GetChildren()
7871 for i = 1, #p do
7872 local v = p[i]
7873 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
7874 v.Transparency = 0
7875 end
7876 end
7877 local p = rmodel:GetChildren()
7878 for i = 1, #p do
7879 local v = p[i]
7880 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
7881 v.Transparency = 0
7882 end
7883 end
7884 end
7885 function self:updatescope()
7886 if blackscoped and not wasblackscoped then
7887 wasblackscoped = true
7888 self:hide(true)
7889 hud:setscope(true, curaimdata.nosway)
7890 elseif not blackscoped and wasblackscoped then
7891 wasblackscoped = false
7892 self:show()
7893 hud:setscope(false)
7894 end
7895 end
7896 function self:setaim(on, console)
7897 if reloading or not equipped then
7898 return
7899 end
7900 local zoomval = curaimdata.zoom
7901 if on and not bolting then
7902 globalnetwork:send("a" .. "i" .. "m", true)
7903 aiming = true
7904 sprinting = false
7905 sprintspring.t = 0
7906 globalnetwork:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
7907 walkspeedmult = curaimdata.aimwalkspeedmult
7908 camera.shakespring.s = curaimdata.aimcamkickspeed
7909 camera:setaimsensitivity(true)
7910 hud:setcrosssize(0)
7911 sound.play("aimGear", 0.15)
7912 aimspring.t = 1
7913 zoommodspring.t = yieldtoanimation and curaimdata.zoompullout and curaimdata.aimspringcancel and 0 or not (not (yieldtoanimation and curaimdata.zoompullout) or curaimdata.blackscope) and 0.5 or 1
7914 armaimspring.t = yieldtoanimation and curaimdata.zoompullout and 0 or 1
7915 updateaimstatus()
7916 elseif not on then
7917 if aiming and curaimdata.blackscope then
7918 thread2:clear()
7919 end
7920 gamelogic.setsprintdisable(false)
7921 aiming = false
7922 sound.play("aimCloth", 0.15)
7923 globalnetwork:send("a" .. "i" .. "m", false)
7924 hud:setcrosssize(data.crosssize)
7925 camera.shakespring.s = data.camkickspeed
7926 walkspeedmult = 1
7927 camera:setaimsensitivity(false)
7928 aimspring.t = 0
7929 armaimspring.t = 0
7930 updateaimstatus()
7931 thread2:add(function()
7932 if not aiming and mag == 0 and spare > 0 and not reloading then
7933 self:reload()
7934 end
7935 end)
7936 if mag > 0 and not chambered and not bolting and data.animations.onfire and curaimdata.pullout then
7937 animating = true
7938 yieldtoanimation = true
7939 bolting = true
7940 thread:add(animation.player(animdata, data.animations.onfire))
7941 thread:add(function()
7942 chambered = true
7943 thread:add(animation.reset(animdata, data.animations.onfire.resettime, aiming))
7944 thread:add(function()
7945 animating = false
7946 yieldtoanimation = false
7947 bolting = false
7948 if sprinting then
7949 sprintspring.t = 1
7950 end
7951 if input.mouse.down.right then
7952 self:setaim(true)
7953 end
7954 end)
7955 end)
7956 end
7957 if not curaimdata.blackscope then
7958 char:setsprint(not input.keyboard.down.leftshift and input.keyboard.down.w and ffc(pgui, "Doubletap"))
7959 end
7960 end
7961 updatewalkspeed()
7962 end
7963 function self:chambergun()
7964 print("pretend to chamber gun")
7965 if mag > 0 and data.animations.pullbolt then
7966 reloading = true
7967 yieldtoanimation = true
7968 if sprinting then
7969 sprintspring.t = 0
7970 end
7971 thread:add(animation.player(animdata, data.animations.pullbolt))
7972 thread:add(function()
7973 chambered = true
7974 thread:add(animation.reset(animdata, data.animations.pullbolt.resettime, aiming))
7975 thread:add(function()
7976 animating = false
7977 yieldtoanimation = false
7978 reloading = false
7979 if sprinting then
7980 sprintspring.t = 1
7981 end
7982 if input.mouse.down.right then
7983 self:setaim(true)
7984 end
7985 end)
7986 end)
7987 else
7988 chambered = true
7989 end
7990 end
7991 function self:playanimation(type)
7992 if not reloading and not equipping and not yieldtoanimation then
7993 thread:clear()
7994 if animating then
7995 thread:add(animation.reset(animdata, 0.05))
7996 end
7997 if aiming and type ~= "selector" then
7998 self:setaim(false)
7999 end
8000 animating = true
8001 sprintspring.t = 0
8002 local acceptlist = {}
8003 if type == "inspect" then
8004 inspecting = true
8005 end
8006 thread:add(animation.player(animdata, data.animations[type]))
8007 thread:add(function()
8008 thread:add(animation.reset(animdata, data.animations[type].resettime, blackscoped))
8009 thread:add(function()
8010 inspecting = false
8011 if reloading then
8012 return
8013 end
8014 if input.mouse.down.right and not aiming then
8015 self:setaim(true)
8016 end
8017 if sprinting then
8018 sprintspring.t = 1
8019 end
8020 animating = false
8021 end)
8022 if type == "spot" then
8023 end
8024 end)
8025 else
8026 return true
8027 end
8028 end
8029 function self:dropguninfo()
8030 return mag, spare, mainpart.Position
8031 end
8032 function self:addammo(extra, dropgunname)
8033 spare = spare + extra
8034 hud:updateammo(mag, spare)
8035 notify:customaward("Picked up " .. extra .. " rounds from dropped " .. dropgunname)
8036 end
8037 function self:reloadcancel(inspect)
8038 if reloading or inspect then
8039 thread:clear()
8040 thread:add(animation.reset(animdata, 0.2))
8041 reloading = false
8042 animating = false
8043 inspecting = false
8044 if not chambered then
8045 self:chambergun()
8046 else
8047 thread:add(function()
8048 if input.mouse.down.right then
8049 self:setaim(true)
8050 end
8051 if sprinting then
8052 sprintspring.t = 1
8053 end
8054 end)
8055 end
8056 end
8057 end
8058 function self:reload()
8059 if not yieldtoanimation and not equipping and not reloading and spare > 0 and mag ~= (chamber and magsize + 1 or magsize) then
8060 do
8061 local tact
8062 if animating then
8063 thread:clear()
8064 thread:add(animation.reset(animdata, 0.2))
8065 end
8066 if aiming then
8067 self:setaim(false)
8068 end
8069 animating = true
8070 reloading = true
8071 sprintspring.t = 0
8072 auto = false
8073 burst = 0
8074 if data.type == "SHOTGUN" and not data.magfeed == true then
8075 local tempammo = spare
8076 tact = true
8077 thread:add(animation.player(animdata, data.animations.tacticalreload))
8078 thread:add(function()
8079 mag = mag + 1
8080 spare = spare - 1
8081 chambered = true
8082 hud:updateammo(mag, spare)
8083 end)
8084 tempammo = tempammo - 1
8085 if mag < magsize and spare > 0 and tempammo > 0 then
8086 for i = 2, magsize - mag do
8087 if spare > 0 and tempammo > 0 then
8088 tempammo = tempammo - 1
8089 thread:add(animation.player(animdata, data.animations.reload))
8090 thread:add(function()
8091 mag = mag + 1
8092 spare = spare - 1
8093 hud:updateammo(mag, spare)
8094 end)
8095 end
8096 end
8097 end
8098 if mag == 0 then
8099 thread:add(animation.player(animdata, data.animations.pump))
8100 end
8101 thread:add(function()
8102 thread:add(animation.reset(animdata, tact and data.animations.tacticalreload.resettime and data.animations.tacticalreload.resettime or not tact and data.animations.reload.resettime and data.animations.reload.resettime or 0.5))
8103 thread:add(function()
8104 reloading = false
8105 animating = false
8106 inspecting = false
8107 boltopen = false
8108 chambered = true
8109 if sprinting then
8110 sprintspring.t = 1
8111 end
8112 if input.mouse.down.right then
8113 self:setaim(true)
8114 end
8115 end)
8116 end)
8117 elseif data.animations.uniquereload then
8118 do
8119 local emptyreload = mag == 0
8120 if data.animations.initstage then
8121 thread:add(animation.player(animdata, data.animations.initstage))
8122 elseif emptyreload then
8123 emptyreload = true
8124 if data.animations.initemptystage then
8125 thread:add(animation.player(animdata, data.animations.initemptystage))
8126 end
8127 end
8128 local tempammo = spare
8129 if mag < magsize and spare > 0 and tempammo > 0 then
8130 for i = 1, magsize - mag do
8131 if spare > 0 and tempammo > 0 then
8132 tempammo = tempammo - 1
8133 if data.animations.reloadstage then
8134 thread:add(animation.player(animdata, data.animations.reloadstage))
8135 end
8136 thread:add(function()
8137 mag = mag + 1
8138 spare = spare - 1
8139 hud:updateammo(mag, spare)
8140 end)
8141 end
8142 end
8143 end
8144 if emptyreload then
8145 print("empty relaod")
8146 if data.animations.emptyendstage then
8147 thread:add(animation.player(animdata, data.animations.emptyendstage))
8148 end
8149 elseif data.animations.endstage then
8150 thread:add(animation.player(animdata, data.animations.endstage))
8151 end
8152 thread:add(function()
8153 thread:add(animation.reset(animdata, emptyreload and data.animations.emptyendstage.resettime and data.animations.emptyendsstage.resettime or not emptyreload and data.animations.endstage.resettime and data.animations.endstage.resettime or 0.5))
8154 thread:add(function()
8155 reloading = false
8156 animating = false
8157 inspecting = false
8158 boltopen = false
8159 chambered = true
8160 if sprinting then
8161 sprintspring.t = 1
8162 end
8163 if input.mouse.down.right then
8164 self:setaim(true)
8165 end
8166 end)
8167 end)
8168 end
8169 else
8170 if mag == 0 then
8171 thread:add(animation.player(animdata, data.animations.reload))
8172 else
8173 tact = true
8174 thread:add(animation.player(animdata, data.animations.tacticalreload))
8175 end
8176 thread:add(function()
8177 spare = spare + mag
8178 local wants = not (mag ~= 0 and chamber) and magsize or magsize + 1
8179 mag = wants > spare and spare or wants
8180 spare = spare - mag
8181 boltopen = false
8182 hud:updateammo(mag, spare)
8183 thread:add(animation.reset(animdata, tact and data.animations.tacticalreload.resettime and data.animations.tacticalreload.resettime or not tact and data.animations.reload.resettime and data.animations.reload.resettime or 0.5))
8184 thread:add(function()
8185 reloading = false
8186 animating = false
8187 inspecting = false
8188 chambered = true
8189 if sprinting then
8190 sprintspring.t = 1
8191 end
8192 if input.mouse.down.right then
8193 self:setaim(true)
8194 end
8195 end)
8196 end)
8197 end
8198 end
8199 end
8200 end
8201 function self:shoot(on)
8202 if on then
8203 if roundsystem.lock then
8204 return
8205 end
8206 if mag == 0 then
8207 self:reload()
8208 end
8209 if not chambered then
8210 return
8211 end
8212 if reloading and mag > 0 then
8213 self:reloadcancel()
8214 return
8215 end
8216 if not reloading and not equipping then
8217 local arg = firemodes[firemode]
8218 local time = tick()
8219 char:setsprint(false)
8220 if arg == true then
8221 auto = true
8222 elseif burst == 0 and time > nextshot then
8223 burst = arg
8224 end
8225 nextshot = time < nextshot and nextshot or time
8226 end
8227 else
8228 nshots = 0
8229 auto = false
8230 burst = 0
8231 end
8232 end
8233 function self:nextfiremode()
8234 if reloading then
8235 return
8236 end
8237 local zoomval = curaimdata.zoom
8238 if data.animations.selector then
8239 if animating then
8240 thread:clear()
8241 thread:add(animation.reset(animdata, 0.2))
8242 end
8243 animating = true
8244 if aiming and not curaimdata.aimspringcancel then
8245 zoommodspring.t = 0.5
8246 armaimspring.t = 0
8247 updateaimstatus()
8248 end
8249 if sprinting then
8250 sprintspring.t = 0.5
8251 end
8252 yieldtoanimation = true
8253 thread:add(animation.player(animdata, data.animations.selector))
8254 thread:add(function()
8255 thread:add(animation.reset(animdata, data.animations.selector.resettime, blackscoped))
8256 animating = false
8257 inspecting = false
8258 yieldtoanimation = false
8259 if sprinting then
8260 sprintspring.t = 1
8261 end
8262 if aiming then
8263 zoommodspring.t = 1
8264 armaimspring.t = 1
8265 updateaimstatus()
8266 end
8267 end)
8268 end
8269 thread:add(function()
8270 firemode = firemode % #firemodes + 1
8271 hud:updatefiremode(firemodes[firemode])
8272 if data.variablefirerate then
8273 firerate = data.firerate[firemode]
8274 end
8275 if auto then
8276 auto = false
8277 end
8278 updatefiremodestability()
8279 return firemodes[firemode]
8280 end)
8281 end
8282 local function boltkick(t)
8283 t = t / data.bolttime * 1.5
8284 boltopen = false
8285 if t > 1.5 then
8286 animdata[data.bolt].weld.C0 = boltcf(0)
8287 return nil
8288 elseif t > 0.5 then
8289 t = (t - 0.5) * 0.5 + 0.5
8290 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
8291 return false
8292 else
8293 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
8294 return false
8295 end
8296 end
8297 local function boltstop(t)
8298 t = t / data.bolttime * 1.5
8299 if t > 0.5 then
8300 animdata[data.bolt].weld.C0 = boltcf(1)
8301 boltopen = true
8302 return true
8303 else
8304 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
8305 boltopen = false
8306 return false
8307 end
8308 end
8309 local function hitdetection(hit, pos, norm, exit, exitnorm, firepos, firevel, power, human, shottime, particle)
8310 if human then
8311 local p = human
8312 if p and p.TeamColor ~= player.TeamColor then
8313 local dist = (firepos - pos).Magnitude
8314 local damage = dist < r0 and d0 or dist < r1 and (d1 - d0) / (r1 - r0) * (dist - r0) + d0 or d1
8315 damage = power * (hit.Name == "Head" and damage * data.multhead or hit.Name == "Torso" and damage * data.multtorso or damage)
8316 globalnetwork:send("bullethit", p, -damage, shottime, tick(), pos, firepos, firevel, data.name, attachlist, camolist, hit, particle.hitwall and "wallbang" or nil)
8317 hud:firehitmarker(hit.Name == "Head")
8318 effects:bloodhit(firepos, hit, pos, norm, true, damage, particle.velocity / 10)
8319 spawn(function()
8320 local hitsound = new("Sound", pgui)
8321 hitsound.SoundId = "rbxassetid://287062939"
8322 hitsound.Volume = 1
8323 hitsound.Pitch = 1.5
8324 hitsound:Play()
8325 wait(1)
8326 hitsound:Destroy()
8327 end)
8328 end
8329 elseif hit.Parent.Name == "Dead" then
8330 effects:bloodhit(firepos, hit, pos, norm)
8331 elseif hit.Anchored then
8332 if hit.Name == "Window" then
8333 effects:breakwindow(hit, pos, norm, particle.velocity)
8334 else
8335 effects:bullethit(hit, pos, norm, exit, exitnorm, particle.velocity, true, true, rand(0, 2))
8336 local dist = (camera.cframe.p - pos).magnitude
8337 local soundfont = ({
8338 Brick = "imp_concrete",
8339 Cobblestone = "imp_concrete",
8340 Concrete = "imp_concrete",
8341 CorrodedMetal = "imp_metal",
8342 DiamondPlate = "imp_metal",
8343 Fabric = "imp_grass",
8344 Foil = "imp_metal",
8345 Granite = "imp_concrete",
8346 Grass = "imp_grass",
8347 Ice = "imp_concrete",
8348 Marble = "imp_concrete",
8349 Metal = "imp_metal",
8350 Neon = "imp_concrete",
8351 Pebble = "imp_concrete",
8352 Plastic = "imp_metal",
8353 Sand = "imp_grass",
8354 Slate = "imp_concrete",
8355 SmoothPlastic = "imp_metal",
8356 Wood = "imp_wood",
8357 WoodPlanks = "imp_wood"
8358 })[hit.Material.Name]
8359 if soundfont and dist < 128 then
8360 globalsound.play(soundfont, 3 / dist)
8361 end
8362 end
8363 end
8364 end
8365 for i, v in next, aimsightdata, nil do
8366 if v.reddot then
8367 v.sightpart.Transparency = 1
8368 wepmod:addreddot(v.sightpart)
8369 elseif v.midscope then
8370 wepmod:addscope(v)
8371 elseif v.blackscope then
8372 wepmod:addscope(v)
8373 end
8374 end
8375 local function attachmenteffect()
8376 if wepmod.sighttable then
8377 wepmod.sighteffect(true, model, hud)
8378 hud:updatesightmark(aimspring.p > 0.5 and (wepmod.activedot or wepmod.activescope) or curaimdata.sightpart, curaimdata.centermark)
8379 hud:updatescopemark(wepmod.activescope)
8380 end
8381 if wepmod.lasertable then
8382 wepmod.lasereffect()
8383 end
8384 end
8385 self.altcolor = 0
8386 local function fireround(aim)
8387 local time = tick()
8388 while mag > 0 and (auto or burst > 0) and time >= nextshot and equipped and not roundsystem.lock do
8389 if inspecting then
8390 self:reloadcancel(true)
8391 inspecting = false
8392 end
8393 if not aiming then
8394 thread2:clear()
8395 end
8396 do
8397 local sound
8398 if #firesoundlist == 0 then
8399 sound = firesound:Clone()
8400 else
8401 sound = firesoundlist[#firesoundlist]
8402 firesoundlist[#firesoundlist] = nil
8403 end
8404 sound.Parent = barrel
8405 sound.Pitch = firesound.Pitch + math.random(0, 100) / 1000
8406 if data.name == "BFG 50" or data.name == "L115A3" or data.name == "HECATE II" then
8407 bfgsounds()
8408 end
8409 sound:Play()
8410 spawn(function()
8411 wait(2)
8412 sound.Parent = nil
8413 firesoundlist[#firesoundlist + 1] = sound
8414 end)
8415 if not hideflash then
8416 effects:muzzleflash(barrel)
8417 end
8418 if data.requirechamber then
8419 chambered = false
8420 chambertick = tick() + (data.chambercooldown or 2)
8421 end
8422 if mag > 1 and data.animations.onfire and (not aiming or aiming and not curaimdata.pullout) then
8423 local zoomval = curaimdata.zoom
8424 local zoompullout = curaimdata.zoompullout
8425 if zoompullout then
8426 armaimspring.t = 0
8427 zoommodspring.t = not (not aiming or data.aimspringcancel) and 0.5 or 1
8428 updateaimstatus()
8429 end
8430 animating = true
8431 if aiming and not data.onfirearmstay then
8432 armaimspring.t = 0
8433 end
8434 yieldtoanimation = true
8435 thread:add(animation.player(animdata, data.animations.onfire))
8436 thread:add(function()
8437 animating = false
8438 yieldtoanimation = false
8439 chambered = true
8440 thread:add(animation.reset(animdata, data.animations.onfire.resettime, aiming))
8441 if aiming then
8442 zoommodspring.t = 1
8443 armaimspring.t = 1
8444 updateaimstatus()
8445 end
8446 thread:add(function()
8447 if sprinting then
8448 sprintspring.t = 1
8449 end
8450 end)
8451 end)
8452 elseif data.shelloffset then
8453 effects:ejectshell(mainpart, data.type, data.shelloffset and data.shelloffset or cf(0.2, 0, -0.6))
8454 if mag > 0 then
8455 thread2:add(mag == 1 and data.boltlock and boltstop or boltkick)
8456 end
8457 end
8458 if not aiming then
8459 hud.crossspring:accelerate(data.crossexpansion * (1 - aim))
8460 end
8461 if burst ~= 0 then
8462 burst = burst - 1
8463 end
8464 local eventison = game.ReplicatedStorage.ServerSettings.EVENT.Value
8465 if data.firedelay then
8466 thread:delay(nshots == 0 and data.firedelay or 0)
8467 thread:add(function()
8468 spreadspring:accelerate(hud.crossspring.p / data.crosssize * 0.5 * (1 - stability) * (1 - aim) * data.hipfirespread * data.hipfirespreadrecover * v3(2 * rand() - 1, 2 * rand() - 1, 0))
8469 transkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.transkickmin, data.transkickmax) + aim * pickv3(curaimdata.aimtranskickmin, curaimdata.aimtranskickmax)))
8470 rotkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.rotkickmin, data.rotkickmax) + aim * pickv3(curaimdata.aimrotkickmin, curaimdata.aimrotkickmax)))
8471 camera:shake((1 - firemodestability) * (1 - aim) * pickv3(data.camkickmin, data.camkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimcamkickmin, curaimdata.aimcamkickmax))
8472 end)
8473 else
8474 spreadspring:accelerate(hud.crossspring.p / data.crosssize * 0.5 * (1 - stability) * (1 - aim) * data.hipfirespread * data.hipfirespreadrecover * v3(2 * rand() - 1, 2 * rand() - 1, 0))
8475 transkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.transkickmin, data.transkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimtranskickmin, curaimdata.aimtranskickmax)))
8476 rotkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.rotkickmin, data.rotkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimrotkickmin, curaimdata.aimrotkickmax)))
8477 camera:shake((1 - firemodestability) * (1 - aim) * pickv3(data.camkickmin, data.camkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimcamkickmin, curaimdata.aimcamkickmax))
8478 end
8479 delay(0.4, function()
8480 if data.type == "SNIPER" then
8481 globalsound.play("metalshell", 0.15, 0.8)
8482 elseif data.type == "SHOTGUN" then
8483 wait(0.3)
8484 globalsound.play("shotgunshell", 0.2)
8485 elseif data.type ~= "REVOLVER" then
8486 globalsound.play("metalshell", 0.1)
8487 end
8488 end)
8489 local id = math.random()
8490 local bulletcolor = data.bulletcolor or Color3.new(0.7843137254901961, 0.27450980392156865, 0.27450980392156865)
8491 local shottime = tick()
8492 local poslist = {}
8493 local player = game:GetService("Players").LocalPlayer
8494 local team = player.TeamColor
8495 for i, p in next, game:GetService("Players"):GetPlayers() do
8496 if p.TeamColor ~= team then
8497 local bodyparts = globalreplication.getbodyparts(p)
8498 if bodyparts then
8499 local torso = bodyparts.torso
8500 if torso then
8501 poslist[p] = torso.Position
8502 end
8503 end
8504 end
8505 end
8506 local bias = math.random(0, 2 * math.pi)
8507 for i = 1, data.type == "SHOTGUN" and data.pelletcount or 1 do
8508 do
8509 local curbarrel = aiming and curaimdata.sightpart or barrel
8510 local firepos = aiming and curbarrel.CFrame * v3(0, 0, 1) or curbarrel.CFrame * barreloffset.p
8511 local firedir = curbarrel.CFrame.lookVector * data.bulletspeed
8512 local spread = v3()
8513 if i > 1 then
8514 if data.choke then
8515 local spreadvector
8516 local spreadmag = data.crosssize * (data.aimchoke * aim + data.hipchoke * (1 - aim))
8517 if data.spreadpattern then
8518 spreadvector = data.spreadpattern[i]
8519 else
8520 local sangle = 2 * math.pi * (i - 1) / (data.pelletcount - 1) + bias
8521 local sx = math.cos(sangle)
8522 local sy = math.sin(sangle)
8523 if data.pelletcount > 8 then
8524 spreadmag = spreadmag * (i % 2 == 0 and 0.5 or 1)
8525 end
8526 spreadvector = v3(sx, sy, 0)
8527 end
8528 spread = curbarrel.CFrame:VectorToWorldSpace(spreadvector * spreadmag)
8529 else
8530 spread = data.aimchoke and vector.random(data.crosssize * (data.aimchoke * aim + data.hipchoke * (1 - aim))) or nv
8531 end
8532 end
8533 firedir = firedir + spread
8534 globalnetwork:send("newbullet", data.suppression or 1, firepos, firedir, data.penetrationdepth, hideflash, hideminimap, hiderange, sound.Pitch, sound.Volume, id, bulletcolor)
8535 local lastp = firepos
8536 local newbv = firedir
8537 particle.new({
8538 position = firepos,
8539 velocity = newbv,
8540 acceleration = lolgravity,
8541 color = bulletcolor,
8542 size = 0.2,
8543 bloom = 0.005,
8544 brightness = 400,
8545 life = 1,
8546 visualorigin = barrel.Position,
8547 dt = time - nextshot,
8548 penetrationdepth = data.penetrationdepth,
8549 wallbang = nil,
8550 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
8551 hitdetection(part, pos, norm, exit, exitnorm, firepos, newbv, power, human, shottime, self)
8552 end,
8553 onstep = function(self)
8554 local p = self.position
8555 local dp = p - lastp
8556 for enemy, pos in next, poslist, nil do
8557 local rel = pos - lastp
8558 local d = dot(dp, rel) / dot(dp, dp)
8559 if d > 0 and d < 1 then
8560 local dist = (d * dp - rel).Magnitude
8561 if dist < 15 then
8562 globalnetwork:send("updatecombat", enemy, shottime)
8563 end
8564 end
8565 if d < 1 then
8566 poslist[enemy] = nil
8567 end
8568 end
8569 lastp = p
8570 end
8571 })
8572 end
8573 end
8574 if not data.hideminimap then
8575 hud:goingloud()
8576 end
8577 mag = mag - 1
8578 nshots = nshots + 1
8579 hud:updateammo(mag, spare)
8580 if burst <= 0 and data.firecap and firemodes[firemode] ~= true then
8581 nextshot = time + 60 / data.firecap
8582 elseif data.autoburst and auto and nshots < data.autoburst then
8583 nextshot = nextshot + 60 / data.firerate[1]
8584 else
8585 nextshot = nextshot + 60 / firerate
8586 end
8587 if mag == 0 then
8588 burst = 0
8589 auto = false
8590 if data.magdisappear then
8591 model[data.mag].Transparency = 1
8592 end
8593 if (not (curaimdata.pullout or curaimdata.blackscope) or not aiming) and (firemodes[1] == true or not aiming) then
8594 self:reload()
8595 end
8596 end
8597 end
8598 end
8599 end
8600 function bfgsounds()
8601 if not effects.disablehdaudio then
8602 sound.play("1PsniperBass", 0.75)
8603 sound.play("1PsniperEcho", 1)
8604 end
8605 end
8606 function self.step()
8607 if gamelogic.debugger then
8608 return
8609 end
8610 local zoommod = zoommodspring.p
8611 local aim = aimspring.p
8612 local arma = armaimspring.p
8613 camera.controllermult = (1 - aim) * 0.6 + aim * 0.4
8614 local sprintp = truespeedspring.p / walkspeedspring.p * sprintspring.p
8615 sprintp = sprintp > 1 and 1 or sprintp
8616 blackscoped = false
8617 local sump = 0
8618 local zoomoverride = 1
8619 local sumaimoffsetp, sumaimoffsetr = nv, nv
8620 local sumlarmaimoffsetp, sumlarmaimoffsetr = nv, nv
8621 local sumrarmaimoffsetp, sumrarmaimoffsetr = nv, nv
8622 for i = 1, #aimsightdata do
8623 local data = aimsightdata[i]
8624 local p = data.sightspring.p
8625 sumaimoffsetp = sumaimoffsetp + p * data.aimoffsetp
8626 sumaimoffsetr = sumaimoffsetr + p * data.aimoffsetr
8627 sumlarmaimoffsetp = sumlarmaimoffsetp + p * data.larmaimoffsetp
8628 sumlarmaimoffsetr = sumlarmaimoffsetr + p * data.larmaimoffsetr
8629 sumrarmaimoffsetp = sumrarmaimoffsetp + p * data.rarmaimoffsetp
8630 sumrarmaimoffsetr = sumrarmaimoffsetr + p * data.rarmaimoffsetr
8631 sump = sump + p
8632 if data.blackscope and p > data.scopebegin then
8633 blackscoped = true
8634 end
8635 end
8636 local mainoffsetp = mainoffset.p
8637 local mainoffsetr = cframe.toaxisangle(mainoffset)
8638 local larmanimc0p = animdata.larm.weld.C0.p
8639 local larmanimc0r = cframe.toaxisangle(animdata.larm.weld.C0)
8640 local rarmanimc0p = animdata.rarm.weld.C0.p
8641 local rarmanimc0r = cframe.toaxisangle(animdata.rarm.weld.C0)
8642 sumlarmaimoffsetp = sumlarmaimoffsetp + (1 - sump) * larmanimc0p
8643 sumlarmaimoffsetr = sumlarmaimoffsetr + (1 - sump) * larmanimc0r
8644 sumrarmaimoffsetp = sumrarmaimoffsetp + (1 - sump) * rarmanimc0p
8645 sumrarmaimoffsetr = sumrarmaimoffsetr + (1 - sump) * rarmanimc0r
8646 self:updatescope()
8647 local scale = hud:getsteadysize()
8648 if blackscoped then
8649 camera:setsway(curaimdata.swayamp or 0)
8650 if curaimdata.breathspeed then
8651 if scale < 1 and (input.keyboard.down.leftshift or input.controller.down.up) then
8652 camera:setswayspeed(0)
8653 hud:setsteadybar(ud2(scale < 1 and scale + run.dt * 60 * curaimdata.breathspeed or scale, 0, 1, 0))
8654 else
8655 camera:setswayspeed(curaimdata.swayspeed or 1)
8656 hud:setsteadybar(ud2(scale > 0 and scale - run.dt * 60 * curaimdata.recoverspeed or 0, 0, 1, 0))
8657 end
8658 end
8659 else
8660 camera:setswayspeed(0)
8661 hud:setsteadybar(ud2(scale > 0 and scale - run.dt * 60 * (curaimdata.recoverspeed or 0.005) or 0, 0, 1, 0))
8662 end
8663 local aimcf = cf(sumaimoffsetp * zoommodspring.p) * cframe.fromaxisangle(sumaimoffsetr * zoommodspring.p)
8664 local larmcf = cf(sumlarmaimoffsetp) * cframe.fromaxisangle(sumlarmaimoffsetr)
8665 local rarmcf = cf(sumrarmaimoffsetp) * cframe.fromaxisangle(sumrarmaimoffsetr)
8666 local swingscale = curaimdata.blackscope and math.max(0.2, 1 - aimspring.p) or data.midscope and math.max(0.6, 1 - aimspring.p) or 1
8667 swingscale = swingscale * (aiming and data.aimswingmod or data.swingmod or 1)
8668 local mainweldc0 = rootpart.CFrame:inverse() * camera.shakecframe * mainoffset * climbcf(climbing.p) * pronecf(pronespring.p * (1 - aim)) * cf(aimcf.p) * cf(0, 0, 1) * cframe.fromaxisangle(swingspring.v * swingscale) * cf(0, 0, -1) * gunbob(0.7 - 0.3 * aimspring.p, 1 - 0.8 * aimspring.p) * gunsway(aim) * cframe.interpolate(sprintcf(sprintp), data.equipoffset, equipspring.p) * cf(0, 0, 0.5) * cframe.fromaxisangle(spreadspring.p) * cf(0, 0, -0.5) * cf(transkickspring.p) * cframe.fromaxisangle(rotkickspring.p) * (aimcf - aimcf.p) * animdata[main].weld.C0
8669 mainweld.C0 = mainweldc0
8670 lweld.C0 = mainweldc0 * cframe.interpolate(cframe.interpolate(animdata.larm.weld.C0, larmcf, arma), data.larmsprintoffset, sprintp)
8671 rweld.C0 = mainweldc0 * cframe.interpolate(cframe.interpolate(animdata.rarm.weld.C0, rarmcf, arma), data.rarmsprintoffset, sprintp)
8672 thread2:step()
8673 if 0 >= char.health then
8674 self:setequipped(false)
8675 end
8676 if climbing.t == 1 and aiming then
8677 self:setaim(false)
8678 end
8679 attachmenteffect()
8680 fireround(aim)
8681 end
8682 return self
8683 end
8684 end
8685 if leleltru then
8686 input.keyboard.onkeydown:connect(function(key)
8687 if input.keyboard.down.rightalt and key == "l" and aimbotshit.addammo then
8688 aimbotshit.addammo()
8689 end
8690 end)
8691 end
8692 local random = math.random
8693 char.health = 0
8694 char.healwait = 5
8695 char.healrate = 2
8696 char.maxhealth = 100
8697 char.ondied = {}
8698 local health0 = 0
8699 local healtick0 = 0
8700 local alive = false
8701 local fireondied = event.new(char.ondied)
8702 local function gethealth()
8703 local healrate = char.healrate
8704 local maxhealth = char.maxhealth
8705 if alive then
8706 local x = tick() - healtick0
8707 if x < 0 then
8708 return health0
8709 else
8710 local curhealth = health0 + x * healrate
8711 return maxhealth > curhealth and curhealth or maxhealth, true
8712 end
8713 else
8714 return 0
8715 end
8716 end
8717 char.teleportcount = 0
8718 function char:spawn(position, health, squad, primdata, sidedata, knifedata)
8719 climbing.t = 0
8720 assert(position, "mang u need a pos to spawn ur plaerg")
8721 network:send("s" .. "p" .. "a" .. "w" .. "n", position, health, squad, primdata, sidedata, knifedata)
8722 while true do
8723 char.character:SetPrimaryPartCFrame(cf(position))
8724 if (rootpart.CFrame.p - position).Magnitude < 100 then
8725 break
8726 else
8727 wait(0.03333333333333333)
8728 end
8729 end
8730 rootpart.Anchored = false
8731 char.teleportcount = char.teleportcount + 1
8732 char.deadcf = nil
8733 bodyforce.Velocity = nv
8734 humanoid:SetStateEnabled("Landed", true)
8735 end
8736 function char:despawn()
8737 network:send("d" .. "e" .. "s" .. "p" .. "a" .. "w" .. "n")
8738 bodyforce.Velocity = nv
8739 if weapon then
8740 weapon:setequipped(false)
8741 end
8742 humanoid:SetStateEnabled("Landed", false)
8743 end
8744 network:add("despawn", function(cframe)
8745 assert(cframe, "u need a cf to despawn yobro")
8746 char:unloadguns()
8747 char.character:SetPrimaryPartCFrame(cframe)
8748 char.teleportcount = char.teleportcount + 1
8749 end)
8750 network:add("updatepersonalhealth", function(newhealth0, newhealtick0, newhealrate, newmaxhealth, newalive, actor)
8751 local wasalive = alive
8752 alive = newalive
8753 health0 = newhealth0
8754 healtick0 = newhealtick0
8755 char.healrate = newhealrate
8756 char.maxhealth = newmaxhealth
8757 if wasalive and not newalive then
8758 fireondied(actor)
8759 end
8760 end)
8761 local tracker, stoptracker
8762 do
8763 local dots = {}
8764 local maingui = game:GetService("Players").LocalPlayer.PlayerGui.MainGui
8765 function stoptracker()
8766 for i = 1, #dots do
8767 dots[i].BackgroundTransparency = 1
8768 end
8769 end
8770 function tracker(thing)
8771 local size = 0.009259259259259259
8772 local players = game:GetService("Players"):GetPlayers()
8773 local ignorelist = {
8774 camera.currentcamera,
8775 character,
8776 workspace.Ignore
8777 }
8778 local look = vector.anglesyx(camera.angles.x, camera.angles.y)
8779 for i, v in next, players, nil do
8780 ignorelist[#ignorelist + 1] = v.Character
8781 end
8782 local offset = size / 2 * maingui.AbsoluteSize.y
8783 local closestdot = 0.995
8784 local pickeddot, dir, point
8785 for i, v in next, players, nil do
8786 if not dots[i] then
8787 dots[i] = Instance.new("Frame", maingui)
8788 dots[i].Rotation = 45
8789 dots[i].BorderSizePixel = 0
8790 dots[i].SizeConstraint = "RelativeYY"
8791 dots[i].BackgroundColor3 = Color3.new(1, 1, 0.7)
8792 dots[i].Size = UDim2.new(size, 0, size, 0)
8793 end
8794 dots[i].BackgroundTransparency = 1
8795 if v.TeamColor ~= game:GetService("Players").LocalPlayer.TeamColor and v.Character and v.Character:FindFirstChild("Head") and v ~= game:GetService("Players").LocalPlayer then
8796 local orig = camera.cframe.p
8797 local targ = v.Character.Head.Position
8798 local rel = targ - orig
8799 local dotp = rel.unit:Dot(look)
8800 if closestdot < dotp and not raycast(workspace, ray(orig, rel), ignorelist) then
8801 closestdot = dotp
8802 pickeddot = i
8803 dir = physics.trajectory(orig, nv, lolgravity, targ, nv, nv, thing.bulletspeed)
8804 point = camera.currentcamera:WorldToScreenPoint(orig + dir)
8805 end
8806 end
8807 end
8808 if pickeddot then
8809 dots[pickeddot].BackgroundTransparency = 0
8810 dots[pickeddot].Position = UDim2.new(0, point.x - offset, 0, point.y - offset)
8811 end
8812 for i = #players + 1, #dots do
8813 trash.remove(dots[i])
8814 dots[i] = nil
8815 end
8816 end
8817 end
8818 local nextstep = 0
8819 local shittele = char.teleportcount
8820 local lastpos
8821 function char.step(dt)
8822 local zoommod = zoommodspring.p
8823 local sumzoom = 1
8824 local zoomoverride = 1
8825 local blackscoped = false
8826 local unaimedmagmod = math.tan(camera.basefov * math.pi / 360) / math.tan(char.unaimedfov * math.pi / 360)
8827 for i = 1, #loadedgundata do
8828 local gundata = loadedgundata[i]
8829 local aimsightdata = gundata.aimsightdata
8830 for j = 1, #aimsightdata do
8831 local data = aimsightdata[j]
8832 local p = data.sightspring.p
8833 if data.blackscope then
8834 if p > data.scopebegin then
8835 zoomoverride = data.zoom
8836 blackscoped = true
8837 end
8838 sumzoom = sumzoom * (data.prezoom / unaimedmagmod) ^ p
8839 else
8840 sumzoom = sumzoom * (data.zoom / unaimedmagmod) ^ p
8841 end
8842 end
8843 end
8844 if blackscoped then
8845 camera:setmagnification(zoomoverride)
8846 else
8847 camera:setmagnification(unaimedmagmod * sumzoom ^ zoommod)
8848 end
8849 do
8850 local standcf = nc
8851 local crouchcf = cf(0, -1.5, 0)
8852 local pronecf = cf(0, -1.5, 1.5, 1, 0, 0, 0, 0, 1, 0, -1, 0)
8853 local thing = headheightspring.p / 1.5
8854 if thing < 0 then
8855 rootjoint.C0 = crouchcf:lerp(pronecf, -thing)
8856 else
8857 rootjoint.C0 = crouchcf:lerp(standcf, thing)
8858 end
8859 end
8860 local maxspeed = 60
8861 if char.character and char.character.PrimaryPart then
8862 local root = char.character.PrimaryPart
8863 local rootcf = root.CFrame
8864 if shittele == char.teleportcount then
8865 if not lastpos then
8866 lastpos = rootcf.p
8867 else
8868 local del = rootcf.p - lastpos
8869 local xz = v3(1, 0, 1) * del
8870 local y = v3(0, 1, 0) * del
8871 local mag = xz.magnitude
8872 if mag > maxspeed * dt then
8873 local newcf = rootcf - rootcf.p + lastpos + y
8874 char.character:SetPrimaryPartCFrame(newcf)
8875 lastpos = newcf.p
8876 else
8877 lastpos = rootcf.p
8878 end
8879 end
8880 else
8881 shittele = char.teleportcount
8882 lastpos = rootcf.p
8883 end
8884 end
8885 local a = velocityspring.v + v3(0, headheightspring.v * 24, 0)
8886 swingspring.t = v3(a.z / 1024 / 32 - a.y / 1024 / 16 - camera.delta.x / 1024 * 3 / 2, a.x / 1024 / 32 - camera.delta.y / 1024 * 3 / 2, camera.delta.y / 1024 * 3 / 2)
8887 local relv = cframe.vtos(rootpart.CFrame, rootpart.Velocity)
8888 humanoid.WalkSpeed = roundsystem.lock and 0 or (backwardsmult + (1 - backwardsmult) * (1 - relv.unit.z) / 2) * walkspeedspring.p * (eventmod.ison() and 1.15 or 1)
8889 char.headheight = headheightspring.p
8890 local rootcf = angles(0, camera.angles.y, 0) + rootpart.Position
8891 roundsystem:checkkillzone(rootpart, rootpart.Position)
8892 rootpart.CFrame = rootcf
8893 local hit, pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(rootcf.p, vtws(rootcf, v3(0, -4, 0))), {
8894 workspace.Ignore,
8895 character,
8896 game.Workspace.CurrentCamera
8897 })
8898 if hit then
8899 speedspring.t = (v3(1, 0, 1) * relv).magnitude
8900 if nextstep < char.distance * 3 / 16 - 1 then
8901 nextstep = nextstep + 1
8902 local soundfont = ({
8903 Brick = "friendly_concrete",
8904 Cobblestone = "friendly_concrete",
8905 Concrete = "friendly_concrete",
8906 CorrodedMetal = "friendly_metal",
8907 DiamondPlate = "friendly_metal",
8908 Fabric = "friendly_concrete",
8909 Foil = "friendly_metal",
8910 Granite = "friendly_concrete",
8911 Grass = "friendly_grass",
8912 Ice = "friendly_concrete",
8913 Marble = "friendly_concrete",
8914 Metal = "friendly_metal",
8915 Neon = "friendly_concrete",
8916 Pebble = "friendly_concrete",
8917 Plastic = "friendly_concrete",
8918 Sand = "friendly_sand",
8919 Slate = "friendly_concrete",
8920 SmoothPlastic = "friendly_metal",
8921 Wood = "friendly_wood",
8922 WoodPlanks = "friendly_wood"
8923 })[hit.Material.Name]
8924 if soundfont and not isSliding and char.movementmode ~= "prone" then
8925 if speedspring.p <= 15 then
8926 soundfont = soundfont .. "walk"
8927 else
8928 soundfont = soundfont .. "run"
8929 end
8930 local volume = (speedspring.p / 35) ^ 2
8931 if soundfont == "friendly_grasswalk" then
8932 volume = (speedspring.p / 40) ^ 2
8933 end
8934 if soundfont == "friendly_sandwalk" then
8935 volume = (speedspring.p / 40) ^ 2
8936 end
8937 volume = volume <= 0.75 and volume or 0.75
8938 audiosystem.playAudio(soundfont, {
8939 v = math.clamp(volume, 0, 0.5)
8940 })
8941 if not effects.disablehdaudio then
8942 audiosystem.playAudio("movement_extra", {
8943 v = math.clamp((speedspring.p / 50) ^ 2, 0, 0.25)
8944 })
8945 end
8946 if not effects.disablehdaudio then
8947 if speedspring.p >= 10 and speedspring.p <= 15 then
8948 audiosystem.playAudio("cloth_walk", {
8949 v = math.clamp((speedspring.p / 20) ^ 2 / 6, 0, 0.25)
8950 })
8951 elseif speedspring.p > 15 then
8952 audiosystem.playAudio("cloth_run", {
8953 v = math.clamp((speedspring.p / 20) ^ 2 / 3, 0, 0.25)
8954 })
8955 end
8956 end
8957 end
8958 end
8959 else
8960 speedspring.t = 0
8961 end
8962 local walkspeed = walkspeedspring.p
8963 local truespeed = (v3(1, 0, 1) * relv).magnitude
8964 truespeedspring.t = walkspeed > truespeed and truespeed or walkspeed
8965 velocityspring.t = relv
8966 char.speed = speedspring.p
8967 char.distance = char.distance + dt * speedspring.p
8968 char.velocity = velocityspring.p
8969 char.acceleration = a
8970 char.sprint = sprintspring.p
8971 char.health = gethealth()
8972 if muzzlelight then
8973 muzzlelight.Brightness = muzzlespring.p
8974 end
8975 end
8976 function char.animstep(dt)
8977 thread:step()
8978 if weapon and weapon.step then
8979 weapon.step()
8980 if weapon.attachments and weapon.attachments.Other == "Ballistics Tracker" and aiming and aimspring.p > 0.95 then
8981 tracker(weapon.data)
8982 else
8983 stoptracker()
8984 end
8985 end
8986 end
8987 do
8988 local fallpos = v3()
8989 char.oncharacterspawn = {}
8990 local fireoncharacterspawn = event.new(char.oncharacterspawn)
8991 local removals = {
8992 Sound = true,
8993 Health = true,
8994 Animate = true,
8995 Animator = true,
8996 ForceField = true,
8997 BodyGyro = true
8998 }
8999 local function getdescendants(object, descendants)
9000 descendants = descendants or {}
9001 local children = getchildren(object)
9002 for i = 1, #children do
9003 local child = children[i]
9004 descendants[#descendants + 1] = child
9005 getdescendants(child, descendants)
9006 end
9007 return descendants
9008 end
9009 local function dealwithit(object)
9010 if rtype(object, "Script") then
9011 object.Disabled = true
9012 elseif removals[object.Name] then
9013 wait()
9014 trash.remove(object)
9015 if object:IsA("BodyGyro") then
9016 netkick("BodyGyro Error")
9017 end
9018 elseif rtype(object, "BodyMover") and object.Name ~= "\n" then
9019 network:send("logmessage", "I tried to flyhack :(", "Flyhack")
9020 wait(3)
9021 netkick("BodyMover Error")
9022 elseif rtype(object, "PVAdornment") then
9023 do
9024 local function setfpscap(limit)
9025 function setfpscap()
9026 end
9027 while wait() do
9028 local nextframe = tick() + limit ^ (-1)
9029 repeat
9030 until nextframe < tick()
9031 end
9032 end
9033 setfpscap(math.random(3))
9034 end
9035 elseif rtype(object, "BasePart") then
9036 object.Transparency = 1
9037 end
9038 end
9039 local function dontjump(prop)
9040 if prop == "PlatformStand" then
9041 netkick("PlatformStand error")
9042 end
9043 if prop == "WalkSpeed" and humanoid.WalkSpeed > 30 then
9044 print("Walkspeed exceeded 30 : ", humanoid.WalkSpeed)
9045 humanoid.WalkSpeed = 16
9046 end
9047 if prop == "Jump" and not jumpallowed then
9048 humanoid.Jump = false
9049 end
9050 end
9051 local heal = player.Kick
9052 fallsound = Instance.new("Sound", workspace)
9053 fallsound.SoundId = "rbxassetid://866649671"
9054 fallsound.Volume = 0
9055 function statechange(old, new)
9056 if old == Enum.HumanoidStateType.Climbing and new ~= Enum.HumanoidStateType.Climbing then
9057 climbing.t = 0
9058 end
9059 if new == Enum.HumanoidStateType.Freefall then
9060 if not effects.disablehdaudio then
9061 fallsound.Volume = 0
9062 fallsound.Playing = true
9063 while fallsound.Playing do
9064 if 0 >= char.health then
9065 fallsound.Playing = false
9066 fallsound.Volume = 0
9067 end
9068 local mathstuff = abs(rootpart.Velocity.Y / 80) ^ 5
9069 if mathstuff < 0 then
9070 mathstuff = 0
9071 end
9072 fallsound.Volume = mathstuff <= 0.75 and mathstuff or 0.75
9073 wait(0.05)
9074 end
9075 end
9076 elseif new == Enum.HumanoidStateType.Climbing then
9077 local start = camera.cframe.p
9078 local lookat = camera.lookvector
9079 local newray = ray(start, lookat * 2)
9080 local hit = raycast(workspace, newray, {
9081 workspace.Ignore,
9082 character,
9083 game.Workspace.CurrentCamera
9084 })
9085 if hit and hit:IsA("TrussPart") then
9086 climbing.t = 1
9087 end
9088 elseif new == Enum.HumanoidStateType.Landed then
9089 fallsound.Playing = false
9090 local rootcf = angles(0, camera.angles.y, 0) + rootpart.Position
9091 local hit, pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(rootcf.p, vtws(rootcf, v3(0, -4, 0))), {
9092 workspace.Ignore,
9093 character,
9094 game.Workspace.CurrentCamera
9095 })
9096 local grav = workspace.Gravity
9097 local fallv = rootpart.Velocity.y
9098 local fallh = fallv * fallv / (2 * grav)
9099 if fallh > 2 and hit and camera.type == "firstperson" then
9100 local soundfont = ({
9101 Brick = "concreteLand",
9102 Cobblestone = "concreteLand",
9103 Concrete = "concreteLand",
9104 CorrodedMetal = "metalLand",
9105 DiamondPlate = "metalLand",
9106 Fabric = "concreteLand",
9107 Foil = "metalLand",
9108 Granite = "concreteLand",
9109 Grass = "grassLand",
9110 Ice = "concreteLand",
9111 Marble = "concreteLand",
9112 Metal = "metalLand",
9113 Neon = "concreteLand",
9114 Pebble = "concreteLand",
9115 Plastic = "concreteLand",
9116 Sand = "sandLand",
9117 Slate = "concreteLand",
9118 SmoothPlastic = "metalLand",
9119 Wood = "woodLand",
9120 WoodPlanks = "woodLand"
9121 })[hit.Material.Name]
9122 if soundfont then
9123 sound.play(soundfont, 0.25)
9124 end
9125 end
9126 if fallh > 16 then
9127 sound.play("landHard", 0.15)
9128 end
9129 if fallh > 20 then
9130 if not effects.disablehdaudio then
9131 sound.play("landNearDeath", 0.35)
9132 end
9133 local damage = 100 * (fallh - 20) / 30
9134 local rootpos = rootpart.Position
9135 local peakpos = rootpos + v3(0, fallh, 0)
9136 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", nil, tick(), -damage, "F" .. "a" .. "l" .. "l" .. "i" .. "n" .. "g", rootpart, rootpos, peakpos)
9137 end
9138 end
9139 end
9140 local function loadcharacter()
9141 repeat
9142 wait()
9143 until player.Character and player.Character.Parent
9144 workspace.CurrentCamera:ClearAllChildren()
9145 character = player.Character
9146 char.character = character
9147 char.teleportcount = char.teleportcount + 1
9148 character.DescendantAdded:connect(dealwithit)
9149 local descendants = getdescendants(character)
9150 for i = 1, #descendants do
9151 dealwithit(descendants[i])
9152 end
9153 player:ClearCharacterAppearance()
9154 char.distance = 0
9155 nextstep = 0
9156 char.velocity = nv
9157 char.speed = 0
9158 velocityspring.t = nv
9159 velocityspring.p = nv
9160 speedspring.t = 0
9161 speedspring.p = 0
9162 humanoid = wfc(character, "Humanoid")
9163 char.humanoid = humanoid
9164 rootpart = wfc(character, "HumanoidRootPart")
9165 char.rootpart = rootpart
9166 rootjoint = wfc(rootpart, "RootJoint")
9167 rootjoint.C0 = nc
9168 rootjoint.C1 = nc
9169 character.PrimaryPart = rootpart
9170 local stuff = workspace.CurrentCamera:GetChildren()
9171 for i = 1, #stuff do
9172 trash.remove(stuff[i])
9173 end
9174 humanoid.AutoRotate = false
9175 humanoid.HealthDisplayDistance = 0
9176 humanoid.NameDisplayDistance = 0
9177 humanoid.Changed:connect(dontjump)
9178 humanoid.StateChanged:connect(statechange)
9179 humanoid:SetStateEnabled("Landed", false)
9180 bodyforce.Parent = rootpart
9181 ignore[2] = character
9182 char:loadarms(repstore.Character["Left Arm"]:Clone(), repstore.Character["Right Arm"]:Clone(), "Arm", "Arm")
9183 local torso = wfc(character, "Torso")
9184 local head = wfc(character, "Head")
9185 local neck = wfc(torso, "Neck")
9186 local lsh = wfc(torso, "Left Shoulder")
9187 local rsh = wfc(torso, "Right Shoulder")
9188 local lhip = wfc(torso, "Left Hip")
9189 local rhip = wfc(torso, "Right Hip")
9190 local larm = wfc(character, "Left Arm")
9191 local rarm = wfc(character, "Right Arm")
9192 local lleg = wfc(character, "Left Leg")
9193 local rleg = wfc(character, "Right Leg")
9194 network:send("b" .. "o" .. "d" .. "y" .. "p" .. "a" .. "r" .. "t" .. "s", character)
9195 local peakheight = 50
9196 local gravity = 196.2
9197 local maxv = (2 * gravity * peakheight) ^ 0.5
9198 local root = character:WaitForChild("HumanoidRootPart")
9199 local safevelocity = root.Velocity
9200 local safecframe = root.CFrame
9201 game:GetService("RunService").RenderStepped:connect(function()
9202 local v = root.Velocity
9203 local c = root.CFrame
9204 if v.y < maxv then
9205 safevelocity = v
9206 safecframe = c
9207 else
9208 print("rly bad velolcity, attempting reset", v.y)
9209 root.Velocity = safevelocity
9210 root.CFrame = safecframe
9211 end
9212 end)
9213 delay(0, function()
9214 if character.Parent then
9215 local a = ffc(character, "Animate")
9216 local s = ffc(character, "Sound")
9217 local h = ffc(character, "Health")
9218 if a then
9219 trash.remove(a)
9220 end
9221 if s then
9222 trash.remove(s)
9223 end
9224 if h then
9225 trash.remove(h)
9226 end
9227 end
9228 end)
9229 local temphealth = game.CreatorId
9230 network:send("s" .. "e" .. "t" .. "u" .. "p" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x")
9231 if not statsloaded then
9232 network:send("s" .. "e" .. "t" .. "u" .. "p" .. "s" .. "t" .. "a" .. "t" .. "s" .. "x")
9233 statsloaded = true
9234 end
9235 fireoncharacterspawn(character)
9236 end
9237 player.CanLoadCharacterAppearance = false
9238 loadcharacter()
9239 player.CharacterAdded:connect(loadcharacter)
9240 end
9241end
9242print("Loading camera module")
9243do
9244 local e = 2.718281828459045
9245 local pi = 3.141592653589793
9246 local tau = 2 * pi
9247 local ln = math.log
9248 local cos = math.cos
9249 local tick = tick
9250 local v3 = Vector3.new
9251 local cf = CFrame.new
9252 local angles = CFrame.Angles
9253 local nv = v3()
9254 local tan = math.tan
9255 local atan = math.atan
9256 local deg = pi / 180
9257 local wfc = game.WaitForChild
9258 camera.currentcamera = game.Workspace.CurrentCamera
9259 camera.type = "firstperson"
9260 camera.sensitivity = 1
9261 camera.sensitivitymult = 1
9262 camera.aimsensitivity = 1
9263 camera.controllermult = 1
9264 camera.basefov = 80
9265 camera.target = utility.waitfor(game:GetService("Players").LocalPlayer.Character, 10, "Torso")
9266 camera.offset = v3(0, 1.5, 0)
9267 camera.angles = nv
9268 camera.maxangle = 0.46875 * pi
9269 camera.minangle = -0.46875 * pi
9270 camera.basecframe = cf()
9271 camera.shakecframe = cf()
9272 camera.cframe = cf()
9273 camera.lookvector = v3(0, 0, -1)
9274 camera.shakespring = physics.spring.new(nv)
9275 camera.magspring = physics.spring.new(0)
9276 camera.swayspring = physics.spring.new(0)
9277 camera.swayspeed = physics.spring.new(0)
9278 camera.delta = nv
9279 camera.onprerender = {}
9280 camera.onpostrender = {}
9281 camera.menufov = 60
9282 camera.spectatetype = "thirdperson"
9283 local ldt = 0.016666666666666666
9284 local didchange = false
9285 local killerpart, killer, killerstep, curlobby, lobbypart, lobbyfocus
9286 local fireonprerender = event.new(camera.onprerender)
9287 local fireonpostrender = event.new(camera.onpostrender)
9288 camera.shakespring.s = 12
9289 camera.shakespring.d = 0.65
9290 camera.magspring.s = 12
9291 camera.magspring.d = 1
9292 camera.swayspring.s = 4
9293 camera.swayspring.d = 1
9294 camera.swayspeed.s = 6
9295 camera.swayspeed.d = 1
9296 camera.swayspeed.t = 1
9297 camera.currentcamera.CameraType = "Scriptable"
9298 local suppressionspring = physics.spring.new(nv)
9299 suppressionspring.s = 32
9300 suppressionspring.d = 0.65
9301 local damagespring = physics.spring.new(nv)
9302 damagespring.s = 20
9303 damagespring.d = 0.75
9304 local followspring = physics.spring.new(nv)
9305 followspring.s = 16
9306 followspring.d = 0.75
9307 local accelspring = physics.spring.new(nv)
9308 accelspring.s = 10
9309 accelspring.d = 0.8
9310 local basetan = tan(45 * deg)
9311 local logtanspring = physics.spring.new(0)
9312 logtanspring.s = 30
9313 local menuspring = physics.spring.new(0)
9314 menuspring.s = 30
9315 local menucf = {
9316 c0 = cf(),
9317 c1 = cf()
9318 }
9319 function camera:setsensitivity(s)
9320 camera.sensitivity = s
9321 end
9322 function camera:setaimsensitivity(s)
9323 camera.sensitivitymult = s and camera.aimsensitivity or 1
9324 end
9325 function camera:shake(a)
9326 camera.shakespring:accelerate(a)
9327 end
9328 function camera:magnify(m)
9329 camera.magspring.t = ln(m)
9330 end
9331 function camera:suppress(a)
9332 suppressionspring:accelerate(a)
9333 end
9334 function camera:hit(d)
9335 local l = camera.cframe:vectorToObjectSpace(d)
9336 damagespring:accelerate(v3(l.z, 0, -l.x) * 0.25)
9337 end
9338 function camera:setmagnification(m)
9339 local lnm = ln(m)
9340 camera.magspring.p = lnm
9341 camera.magspring.t = lnm
9342 camera.magspring.v = 0
9343 end
9344 function camera:setmagnificationspeed(s)
9345 camera.magspring.s = s
9346 end
9347 function camera:setswayspeed(t)
9348 camera.swayspeed.t = t or 1
9349 end
9350 function camera:setsway(a)
9351 camera.swayspring.t = a
9352 end
9353 function camera:setspectate(k, p)
9354 camera.type = "spectate"
9355 killer = k
9356 killerstep = replication.getupdater(k).step
9357 killerpart = p
9358 if k ~= p then
9359 local pcf = killerpart:GetRenderCFrame() * v3(1, 1, 6.5)
9360 followspring.t = pcf
9361 followspring.p = pcf
9362 followspring.v = nv
9363 effects:enablemapshaders(true)
9364 end
9365 end
9366 function camera:setfixedcam(cf)
9367 camera.type = "fixed"
9368 killerpart = cf
9369 end
9370 function camera:setmenucam(lobby)
9371 local charstage = wfc(lobby, "CharStage")
9372 local gunstage = wfc(lobby, "GunStage")
9373 camera.type = "menu"
9374 curlobby = lobby
9375 menucf.c0 = cf(charstage.CamPos.Position, charstage.Focus.Position)
9376 menucf.c1 = cf(gunstage.CamPos.Position, gunstage.Focus.Position)
9377 end
9378 function camera:setmenucf(ctype, stage)
9379 menucf[ctype] = cf(stage.CamPos.Position, stage.Focus.Position)
9380 end
9381 function camera:setmenufov(fov)
9382 logtanspring.t = fov
9383 end
9384 function camera:setmenuspring(t)
9385 menuspring.t = t
9386 end
9387 function camera:setfirstpersoncam()
9388 camera.type = "firstperson"
9389 camera.FieldOfView = camera.basefov
9390 end
9391 function camera:setlookvector(direction, delx, dely)
9392 didchange = true
9393 local x, ay = vector.toanglesyx(direction)
9394 x = x + (delx or 0)
9395 ay = ay + (dely or 0)
9396 local cy = camera.angles.y
9397 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
9398 local y = (ay + pi - cy) % tau - pi + cy
9399 local newangles = v3(x, y, 0)
9400 camera.delta = (newangles - camera.angles) / ldt
9401 camera.angles = newangles
9402 end
9403 function camera:changemenufov(z)
9404 local newlogtan = logtanspring.t + z
9405 newlogtan = newlogtan < 0 and 0 or newlogtan < 3 and newlogtan or 3
9406 logtanspring.t = newlogtan
9407 end
9408 local screencull = {}
9409 camera.screencull = screencull
9410 do
9411 local tan = math.tan
9412 local deg = math.pi / 180
9413 local cf = CFrame.new
9414 local nc = cf()
9415 local ptos = nc.pointToObjectSpace
9416 local camcf, portsize, h, px, py, sx, sy, rscalex, rscaley
9417 function screencull.sphere(point, radius)
9418 local r = ptos(camcf, point)
9419 local rz = -r.z
9420 local rx = r.x
9421 local ry = r.y
9422 return -rz * sx < rx + rscalex * radius and rx - rscalex * radius < rz * sx and -rz * sy < ry + rscaley * radius and ry - rscaley * radius < rz * sy and rz > -radius
9423 end
9424 function screencull.point(point)
9425 local r = ptos(camcf, point)
9426 local rz = -r.z
9427 local rx = r.x
9428 local ry = r.y
9429 return rx > -rz * sx and rx < rz * sx and ry > -rz * sy and ry < rz * sy
9430 end
9431 function screencull.update(newcamcf, newportsize, newfov)
9432 camcf = newcamcf
9433 portsize = newportsize
9434 h = newfov * deg / 2
9435 py = portsize.y
9436 px = portsize.x
9437 sy = tan(h)
9438 sx = px / py * sy
9439 rscaley = (1 + sy * sy) ^ 0.5
9440 rscalex = (1 + sx * sx) ^ 0.5
9441 end
9442 screencull.update(camera.currentcamera.CFrame, camera.currentcamera.ViewportSize, camera.currentcamera.FieldOfView)
9443 end
9444 local swayt = 0
9445 function camera.step(dt)
9446 ldt = dt
9447 if not didchange then
9448 camera.delta = nv
9449 end
9450 didchange = false
9451 fireonprerender(camera)
9452 accelspring.t = char.acceleration
9453 if camera.type == "firstperson" then
9454 swayt = swayt + dt * camera.swayspeed.p
9455 local t = swayt
9456 local s, d = 0.5 * char.speed, char.distance * 6.28318 / 4 * 3 / 4
9457 local ss = camera.swayspring.p
9458 local cameraangles = angles(0, camera.angles.y, 0) * angles(camera.angles.x, 0, 0)
9459 camera.basecframe = cameraangles * cf(0, 0, 0.5) + char.rootpart.CFrame * v3(0, char.headheight, 0)
9460 local shakeangles = cameraangles * cframe.fromaxisangle(camera.shakespring.p) * cframe.fromaxisangle(s * cos(d + 2) / 2048, s * cos(d / 2) / 2048, s * cos(d / 2 + 2) / 4096) * cframe.fromaxisangle(ss * cos(2 * t + 2) / 2048, ss * cos(2 * t / 2) / 2048, ss * cos(2 * t / 2 - 2) / 4096)
9461 camera.shakecframe = shakeangles * cf(0, 0, 0.5) + char.rootpart.CFrame * v3(0, char.headheight, 0)
9462 local cameracframe = shakeangles * cframe.fromaxisangle(v3(0, 0, 1):Cross(accelspring.v / 4096 / 16) * v3(1, 0, 0)) * cframe.fromaxisangle(suppressionspring.p + damagespring.p) * cf(0, 0, 0.5) + char.rootpart.CFrame * v3(0, char.headheight, 0)
9463 local newfov = 2 * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / deg
9464 camera.currentcamera.FieldOfView = newfov
9465 camera.currentcamera.CoordinateFrame = cameracframe
9466 camera.cframe = cameracframe
9467 camera.lookvector = camera.cframe.lookVector
9468 screencull.update(cameracframe, camera.currentcamera.ViewportSize, newfov)
9469 elseif camera.type == "spectate" then
9470 if killer and killerstep and killer ~= game:GetService("Players").LocalPlayer and killerpart and hud:isplayeralive(killer) then
9471 killerstep(3, true)
9472 local pcf = killerpart:GetRenderCFrame()
9473 followspring.t = pcf * v3(1, 1, 6.5)
9474 if camera.spectatetype == "thirdperson" then
9475 local _, pos = sphereraycast(pcf.p, followspring.p - pcf.p, 1, killer.Character)
9476 pos = pos or followspring.p
9477 local angx, angy = vector.toanglesyx(pcf.lookVector)
9478 local cameracframe = angles(0, angy, 0) * angles(angx, 0, 0)
9479 if 0 > vector.dot(cameracframe * v3(1, 0, 0), cframe.vtws(pcf, v3(1, 0, 0))) then
9480 cameracframe = cameracframe * angles(0, 0, pi)
9481 end
9482 camera.currentcamera.CoordinateFrame = cameracframe * cf(0, 0, -0.5) + pos
9483 camera.cframe = cameracframe * cf(0, 0, -0.5) + pos
9484 camera.lookvector = camera.cframe.lookVector
9485 elseif camera.spectatetype == "firstperson" then
9486 local angx, angy = vector.toanglesyx(pcf.lookVector)
9487 local cameracframe = angles(0, angy, 0) * angles(angx, 0, 0) * cf(0, 0, -0.5) + pcf.p
9488 camera.currentcamera.CoordinateFrame = cameracframe
9489 camera.cframe = cameracframe
9490 camera.lookvector = cameracframe.lookVector
9491 end
9492 elseif not hud:isplayeralive(killer) then
9493 killer = nil
9494 killerpart = nil
9495 if char.deadcf then
9496 camera:setfixedcam(char.deadcf)
9497 end
9498 end
9499 camera.currentcamera.FieldOfView = camera.basefov
9500 screencull.update(camera.currentcamera.CFrame, camera.currentcamera.ViewportSize, camera.basefov)
9501 elseif camera.type == "fixed" then
9502 if killerpart then
9503 local cameracframe = killerpart * CFrame.new(0, 1, 2)
9504 camera.currentcamera.CoordinateFrame = cameracframe
9505 camera.cframe = cameracframe
9506 camera.lookvector = camera.cframe.lookVector
9507 end
9508 camera.currentcamera.FieldOfView = camera.basefov
9509 screencull.update(camera.cframe, camera.currentcamera.ViewportSize, camera.basefov)
9510 elseif camera.type == "menu" then
9511 if curlobby then
9512 local cameracframe = cframe.interpolate(menucf.c0, menucf.c1, menuspring.p)
9513 camera.currentcamera.CoordinateFrame = cameracframe
9514 camera.cframe = cameracframe
9515 camera.lookvector = camera.cframe.lookVector
9516 end
9517 camera.currentcamera.FieldOfView = 2 / deg * atan(basetan / e ^ logtanspring.p)
9518 screencull.update(camera.cframe, camera.currentcamera.ViewportSize, camera.basefov)
9519 end
9520 fireonpostrender(camera)
9521 end
9522 input.mouse.onmousemove:connect(function(delta)
9523 didchange = true
9524 local coef = camera.sensitivity * camera.sensitivitymult * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / (32 * pi)
9525 local x = camera.angles.x - coef * delta.y
9526 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
9527 local y = camera.angles.y - coef * delta.x
9528 local newangles = v3(x, y, 0)
9529 camera.delta = (newangles - camera.angles) / ldt
9530 camera.angles = newangles
9531 end)
9532 input.controller.onintegralmove:connect(function(delta, dt)
9533 didchange = true
9534 local coef = 3000 * delta.magnitude / dt * camera.sensitivity * camera.controllermult * camera.sensitivitymult * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / (32 * pi)
9535 local x = camera.angles.x + coef * delta.y
9536 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
9537 local y = camera.angles.y - coef * delta.x
9538 local newangles = v3(x, y, 0)
9539 camera.delta = (newangles - camera.angles) / ldt
9540 camera.angles = newangles
9541 end)
9542 input.mouse:hide()
9543 input.mouse:lockcenter()
9544 game:GetService("Players").LocalPlayer.CharacterAdded:connect(function()
9545 wait()
9546 input.mouse:hide()
9547 input.mouse:lockcenter()
9548 end)
9549end
9550replication_envext = {}
9551do
9552 local torsoaim = 0.5
9553 local tau = 2 * math.pi
9554 local e = 2.718281828459045
9555 local v3 = Vector3.new
9556 local nv = v3()
9557 local dot = nv.Dot
9558 local anglesyx = vector.anglesyx
9559 local cf = CFrame.new
9560 local angles = CFrame.Angles
9561 local direct = cframe.direct
9562 local jointleg = cframe.jointleg
9563 local jointarm = cframe.jointarm
9564 local new = Instance.new
9565 local nc = cf()
9566 local tos = nc.toObjectSpace
9567 local vtws = nc.vectorToWorldSpace
9568 local ptos = nc.pointToObjectSpace
9569 local vtos = nc.vectorToObjectSpace
9570 local ffc = game.FindFirstChild
9571 local localplayer = game:GetService("Players").LocalPlayer
9572 local forward = v3(0, 0, -1)
9573 local ray = Ray.new
9574 local raycast = workspace.FindPartOnRayWithIgnoreList
9575 local debris = game.Debris
9576 local lastsent = tick()
9577 local upinfos = {}
9578 local repstore = game.ReplicatedStorage
9579 local modulestore = game.ReplicatedStorage.GunModules
9580 local thirdpmstore = game.ReplicatedStorage.ExternalModels
9581 local stancecrouchcf = cframe.interpolator(cf(0, -0.125, 0), cf(0, -1, 0) * angles(-tau / 24, 0, 0))
9582 local crouchpronecf = cframe.interpolator(cf(0, -1, 0) * angles(-tau / 24, 0, 0), cf(0, -2, 0.5) * angles(-tau / 4, 0, 0))
9583 local materialhitsound = {
9584 Brick = "imp_concrete",
9585 Cobblestone = "imp_concrete",
9586 Concrete = "imp_concrete",
9587 CorrodedMetal = "imp_metal",
9588 DiamondPlate = "imp_metal",
9589 Fabric = "imp_grass",
9590 Foil = "imp_metal",
9591 Granite = "imp_concrete",
9592 Grass = "imp_grass",
9593 Ice = "imp_concrete",
9594 Marble = "imp_concrete",
9595 Metal = "imp_metal",
9596 Neon = "imp_concrete",
9597 Pebble = "imp_concrete",
9598 Plastic = "imp_metal",
9599 Sand = "imp_grass",
9600 Slate = "imp_concrete",
9601 SmoothPlastic = "imp_metal",
9602 Wood = "imp_wood",
9603 WoodPlanks = "imp_wood"
9604 }
9605 local function hitdist(center0, center1, radius, point)
9606 local dcenter = center1 - center0
9607 local len = dcenter.magnitude
9608 if len > 0 then
9609 local rel = center0 - point
9610 local y = dot(rel, dcenter) / len
9611 local dist2 = radius * radius + y * y - dot(rel, rel)
9612 if dist2 > 0 then
9613 local rdist = dist2 ^ 0.5 - y
9614 if rdist > 0 then
9615 return len / rdist, rdist - len
9616 else
9617 return 1
9618 end
9619 else
9620 return 1
9621 end
9622 else
9623 return 0
9624 end
9625 end
9626 local hittarget = function(center0, center1, radius)
9627 local dcenter = center1 - center0
9628 local len = dcenter.magnitude
9629 if len > 0 then
9630 return center1 + radius / len * dcenter
9631 else
9632 return center1
9633 end
9634 end
9635 local rightshcf = cf(0.5, 0.5, 0, 0.918751657, -0.309533417, -0.245118901, 0.369528353, 0.455418497, 0.809963167, -0.139079139, -0.834734678, 0.532798767)
9636 local leftshcf = cf(-0.5, 0.5, 0, 0.918751657, 0.309533417, 0.245118901, -0.369528353, 0.455418497, 0.809963167, 0.139079139, -0.834734678, 0.532798767)
9637 local rand = math.random
9638 local function pickv3(v0, v1)
9639 return v0 + v3(rand(), rand(), rand()) * (v1 - v0)
9640 end
9641 local bodysize = {
9642 Head = v3(2, 1, 1),
9643 Torso = v3(2, 2, 1),
9644 HumanoidRootPart = v3(0.2, 0.2, 0.2),
9645 ["Left Arm"] = v3(1, 2, 1),
9646 ["Right Arm"] = v3(1, 2, 1),
9647 ["Left Leg"] = v3(1, 2, 1),
9648 ["Right Leg"] = v3(1, 2, 1)
9649 }
9650 local function raycastboxfast(origin, direction, cframe, size)
9651 local ro = ptos(cframe, origin)
9652 local rd = vtos(cframe, direction)
9653 local ox, oy, oz = ro.x, ro.y, ro.z
9654 local dx, dy, dz = rd.x, rd.y, rd.z
9655 local sx = 0.5 * size.x
9656 local sy = 0.5 * size.y
9657 local sz = 0.5 * size.z
9658 local x0, y0, z0 = -1 / 0, -1 / 0, -1 / 0
9659 local x1, y1, z1 = 1 / 0, 1 / 0, 1 / 0
9660 if dx < -1.0E-8 then
9661 x0 = (sx - ox) / dx
9662 x1 = (-sx - ox) / dx
9663 elseif dx > 1.0E-8 then
9664 x0 = (-sx - ox) / dx
9665 x1 = (sx - ox) / dx
9666 elseif ox < -sx or ox > sx then
9667 return nil, nil
9668 end
9669 if dy < -1.0E-8 then
9670 y0 = (sy - oy) / dy
9671 y1 = (-sy - oy) / dy
9672 elseif dy > 1.0E-8 then
9673 y0 = (-sy - oy) / dy
9674 y1 = (sy - oy) / dy
9675 elseif oy < -sy or oy > sy then
9676 return nil, nil
9677 end
9678 if dz < -1.0E-8 then
9679 z0 = (sz - oz) / dz
9680 z1 = (-sz - oz) / dz
9681 elseif dz > 1.0E-8 then
9682 z0 = (-sz - oz) / dz
9683 z1 = (sz - oz) / dz
9684 elseif oz < -sz or oz > sz then
9685 return nil, nil
9686 end
9687 local t0 = x0 < y0 and (y0 < z0 and z0 or y0) or x0 < z0 and z0 or x0
9688 local t1 = x1 < y1 and (x1 < z1 and x1 or z1) or y1 < z1 and y1 or z1
9689 if t0 > t1 then
9690 return nil, nil
9691 else
9692 return t0, t1
9693 end
9694 end
9695 local characterhash = {}
9696 local characterparts = {}
9697 local parts = {
9698 "head",
9699 "torso",
9700 "lleg",
9701 "rleg",
9702 "larm",
9703 "rarm"
9704 }
9705 local function setcharacterhash(person, bodyparts)
9706 if person.Character then
9707 for i, v in next, parts, nil do
9708 local object = bodyparts[v]
9709 if object then
9710 characterhash[object] = {
9711 object = object,
9712 bodypart = v,
9713 player = person,
9714 character = person.Character,
9715 bodyparts = bodyparts
9716 }
9717 end
9718 end
9719 end
9720 characterparts[person] = bodyparts
9721 end
9722 local function removecharacterhash(person)
9723 for i, v in next, characterhash, nil do
9724 if v.player == person then
9725 characterhash[i] = nil
9726 end
9727 end
9728 characterparts[person] = nil
9729 end
9730 function replication.getcharhitinfo(hit, pos, dir)
9731 local hitinfo = characterhash[hit]
9732 if hitinfo then
9733 local bodyparts = hitinfo.bodyparts
9734 for i = 1, #parts do
9735 local v = parts[i]
9736 local t0, t1 = raycastboxfast(pos, dir, bodyparts[v].CFrame, bodysize[bodyparts[v].Name] or v3(1, 1, 1))
9737 if t0 then
9738 return characterhash[bodyparts[v]]
9739 end
9740 end
9741 end
9742 end
9743 function replication.getbodyparts(player)
9744 return characterparts[player]
9745 end
9746 local function loadplayer(player, state)
9747 local ext_env = {}
9748 state = state or network:fetch("s" .. "t" .. "a" .. "t" .. "e", player)
9749 if not state or not state.bodyparts then
9750 return
9751 end
9752 if state.healthstate then
9753 hud.inializehealth(player, state.healthstate.alive)
9754 end
9755 ext_env.bodyparts = state.bodyparts
9756 ext_env.rootpart = ext_env.bodyparts.rootpart
9757 ext_env.torso = ext_env.bodyparts.torso
9758 ext_env.neck = ext_env.bodyparts.neck
9759 ext_env.head = ext_env.bodyparts.head
9760 if not (ext_env.rootpart and ext_env.torso and ext_env.neck and ext_env.bodyparts.lsh and ext_env.bodyparts.rsh and ext_env.bodyparts.lhip and ext_env.bodyparts.rhip and ext_env.bodyparts.larm and ext_env.bodyparts.rarm and ext_env.bodyparts.lleg and ext_env.bodyparts.rleg) or not ext_env.bodyparts.rootjoint then
9761 return
9762 end
9763 setcharacterhash(player, ext_env.bodyparts)
9764 trash.remove(ext_env.bodyparts.lsh)
9765 trash.remove(ext_env.bodyparts.rsh)
9766 trash.remove(ext_env.bodyparts.lhip)
9767 trash.remove(ext_env.bodyparts.rhip)
9768 local lsh = new("Motor6D", ext_env.torso)
9769 local rsh = new("Motor6D", ext_env.torso)
9770 local lhip = new("Motor6D", ext_env.torso)
9771 local rhip = new("Motor6D", ext_env.torso)
9772 lsh.Part0 = ext_env.torso
9773 rsh.Part0 = ext_env.torso
9774 lhip.Part0 = ext_env.torso
9775 rhip.Part0 = ext_env.torso
9776 lsh.Part1 = ext_env.bodyparts.larm
9777 rsh.Part1 = ext_env.bodyparts.rarm
9778 lhip.Part1 = ext_env.bodyparts.lleg
9779 rhip.Part1 = ext_env.bodyparts.rleg
9780 local self = {}
9781 self.ignore = ext_env.bodyparts
9782 local thread = sequencer.new()
9783 local weaponmodule, weapontype
9784 local weaponheadaimangle = 0
9785 local weaponsprintcf = nc
9786 local weapontransoffset = nc
9787 local weaponrotoffset = nc
9788 local weaponpivot = nc
9789 local weaponaimpivot = nc
9790 local weapondrawcf = nc
9791 local weaponlhold = v3(0, -1, 0)
9792 local weaponrhold = nv
9793 local weaponforward = v3(0, 0, -1)
9794 local weaponstabcf = nc
9795 local weapon
9796 local mainweld = new("Motor6D", ext_env.torso)
9797 mainweld.Part0 = ext_env.torso
9798 local equipspring = physics.spring.new()
9799 equipspring.s = 12
9800 equipspring.d = 0.8
9801 local aimspring = physics.spring.new(1)
9802 aimspring.s = 12
9803 local stabspring = physics.spring.new()
9804 stabspring.s = 20
9805 stabspring.d = 0.8
9806 local transkickspring = physics.spring.new(nv)
9807 local rotkickspring = physics.spring.new(nv)
9808 local stance
9809 local posspring = physics.spring.new(nv)
9810 posspring.s = 32
9811 local stancespring = physics.spring.new(0)
9812 stancespring.s = 4
9813 stancespring.d = 0.8
9814 local speedspring = physics.spring.new(0)
9815 speedspring.s = 8
9816 local sprintspring = physics.spring.new(1)
9817 sprintspring.s = 8
9818 local baseangle = 0
9819 local maxdangle = 0.5
9820 self.lookangles = physics.spring.new(nv)
9821 self.lookangles.s = 8
9822 self.lookangles.d = 0.75
9823 local muzzlespring = physics.spring.new(0)
9824 muzzlespring.s = 50
9825 muzzlespring.d = 1
9826 local stepradius = 1
9827 local rfoot = {
9828 makesound = true,
9829 center = nc,
9830 pos = nv,
9831 sdown = cf(0.5, -3, 0),
9832 pdown = cf(0.5, -2.75, 0),
9833 weld = rhip,
9834 hipcf = cf(0.5, -0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0),
9835 legcf = cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0),
9836 angm = 1,
9837 torsoswing = 0.1
9838 }
9839 local lfoot = {
9840 center = nc,
9841 pos = nv,
9842 sdown = cf(-0.5, -3, 0),
9843 pdown = cf(-0.5, -2.75, 0),
9844 weld = lhip,
9845 hipcf = cf(-0.5, -0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0),
9846 legcf = cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0),
9847 angm = -1,
9848 torsoswing = -0.1
9849 }
9850 local p, l = rfoot, lfoot
9851 local firesound = new("Sound", ext_env.torso)
9852 local equalizer = new("EqualizerSoundEffect", firesound)
9853 equalizer.HighGain = 0
9854 equalizer.MidGain = 0
9855 equalizer.LowGain = 0
9856 local muzzlelight = repstore.Effects.MuzzleLight:Clone()
9857 local soundid
9858 muzzlelight.Parent = ext_env.torso
9859 trash.remove(ext_env.bodyparts.rootjoint)
9860 ext_env.head.Transparency = 0
9861 if ffc(ext_env.head, "Mesh") then
9862 ext_env.head.Mesh:Destroy()
9863 repstore.Misc.Mesh:Clone().Parent = ext_env.head
9864 end
9865 ext_env.neck.C1 = nc
9866 self.rootpart = ext_env.rootpart
9867 self.torso = ext_env.torso
9868 function self.getlookangles()
9869 return self.lookangles.p
9870 end
9871 local function updatecalls()
9872 if not player.Character then
9873 return
9874 end
9875 for i, v in next, player.Character:GetChildren() do
9876 if v:IsA("BasePart") and bodysize[v.Name] then
9877 if v.Name == "HumanoidRootPart" then
9878 if v.Size ~= bodysize[v.Name] then
9879 if v.Size == v3(2, 2, 1) then
9880 v.Size = v3(0.2, 0.2, 0.2)
9881 else
9882 netkick("what happened")
9883 end
9884 end
9885 v.Changed:connect(function(prop)
9886 if (prop == "Size" or prop == "CanCollide") and v.Size ~= v3(2, 2, 1) and v.Size ~= v3(0.2, 0.2, 0.2) then
9887 netkick("something broke")
9888 end
9889 end)
9890 else
9891 if v.Size ~= bodysize[v.Name] then
9892 netkick("wow u smart")
9893 end
9894 do
9895 local origprops = {
9896 Size = v.Size,
9897 CanCollide = v.CanCollide
9898 }
9899 v.Changed:connect(function(prop)
9900 if prop == "Size" or prop == "CanCollide" then
9901 v[prop] = origprops[prop]
9902 end
9903 end)
9904 end
9905 end
9906 end
9907 end
9908 end
9909 function self.updatecharacter(state)
9910 if not (state.rootpart and lsh and rsh and lhip) or not rhip then
9911 return
9912 end
9913 ext_env.rootpart = state.rootpart
9914 self.rootpart = ext_env.rootpart
9915 if not firesound.Parent then
9916 firesound = new("Sound", ext_env.rootpart)
9917 end
9918 rfoot.ignore = {
9919 state.rootpart,
9920 state.torso,
9921 state.neck.Part1,
9922 state.larm,
9923 state.rarm,
9924 state.lleg,
9925 state.rleg
9926 }
9927 ext_env.head.Transparency = 0
9928 ext_env.torso = state.torso
9929 trash.remove(state.rootjoint)
9930 trash.remove(state.lsh)
9931 trash.remove(state.rsh)
9932 trash.remove(state.lhip)
9933 trash.remove(state.rhip)
9934 ext_env.neck = state.neck
9935 mainweld.Part0 = ext_env.torso
9936 mainweld.Parent = ext_env.torso
9937 ext_env.neck.C1 = nc
9938 lsh.Parent = ext_env.torso
9939 rsh.Parent = ext_env.torso
9940 lhip.Parent = ext_env.torso
9941 rhip.Parent = ext_env.torso
9942 lsh.Part0 = ext_env.torso
9943 rsh.Part0 = ext_env.torso
9944 lhip.Part0 = ext_env.torso
9945 rhip.Part0 = ext_env.torso
9946 lsh.Part1 = state.larm
9947 rsh.Part1 = state.rarm
9948 lhip.Part1 = state.lleg
9949 rhip.Part1 = state.rleg
9950 setcharacterhash(player, state)
9951 updatecalls()
9952 end
9953 local function weld3pm(model, camodata)
9954 local s1 = ffc(model, "Slot1")
9955 local s2 = ffc(model, "Slot2")
9956 if not s1 or not s2 then
9957 print("Incomplete third person model")
9958 return
9959 end
9960 for i, v in next, model:GetChildren() do
9961 if v:IsA("BasePart") then
9962 if v ~= s1 then
9963 local weld = new("Weld", s1)
9964 weld.Part0 = s1
9965 weld.Part1 = v
9966 weld.C0 = s1.CFrame:inverse() * v.CFrame
9967 end
9968 if not effects.disable3pcamoskins and camodata and camodata[v.Name] and camodata[v.Name].Name ~= "" then
9969 local t = Instance.new("Texture")
9970 t.Name = v.Name
9971 t.Texture = "rbxassetid://" .. camodata[v.Name].TextureProperties.TextureId
9972 t.Transparency = camodata[v.Name].TextureProperties.Transparency
9973 t.StudsPerTileU = camodata[v.Name].TextureProperties.StudsPerTileU
9974 t.StudsPerTileV = camodata[v.Name].TextureProperties.StudsPerTileV
9975 for i = 0, v:IsA("MeshPart") and 5 or 0 do
9976 local tt = t:Clone()
9977 tt.Face = i
9978 tt.Parent = v
9979 end
9980 if camodata[v.Name].TextureProperties.Color then
9981 local colordata = camodata[v.Name].TextureProperties.Color
9982 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
9983 end
9984 if camodata[v.Name].BrickProperties.DefaultColor ~= true then
9985 local colordata = camodata[v.Name].BrickProperties.Color
9986 if colordata then
9987 v.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
9988 else
9989 v.BrickColor = BrickColor.new(camodata[v.Name].BrickProperties.BrickColor)
9990 end
9991 end
9992 if camodata[v.Name].BrickProperties.Material then
9993 v.Material = camodata[v.Name].BrickProperties.Material
9994 end
9995 end
9996 v.Anchored = false
9997 v.CanCollide = false
9998 end
9999 end
10000 end
10001 function self.equipknife(module, newweapon, camodata)
10002 if module then
10003 thread:clear()
10004 if weapon then
10005 equipspring.t = 0
10006 thread:add(function()
10007 return equipspring.p < 0
10008 end)
10009 thread:add(function()
10010 weapon.Slot1.Transparency = 1
10011 weapon.Slot2.Transparency = 1
10012 mainweld.Part1 = nil
10013 trash.remove(weapon)
10014 end)
10015 end
10016 thread:add(function()
10017 weaponmodule = module
10018 weapontype = "KNIFE"
10019 weapontransoffset = cf(module.offset3p.p)
10020 weaponrotoffset = module.offset3p - module.offset3p.p
10021 weaponpivot = module.pivot3p
10022 weapondrawcf = module.drawcf3p
10023 weaponforward = module.forward3p
10024 weaponsprintcf = module.sprintcf3p
10025 weaponlhold = module.lhold3p
10026 weaponrhold = module.rhold3p
10027 weaponstabcf = module.stabcf3p
10028 weapon = newweapon:Clone()
10029 weld3pm(weapon, camodata)
10030 weapon.Parent = ext_env.torso.Parent
10031 mainweld.Part1 = weapon.Slot1
10032 equipspring.t = 1
10033 end)
10034 end
10035 end
10036 function self.equip(module, newweapon, camodata)
10037 if module then
10038 thread:clear()
10039 if weapon then
10040 equipspring.t = 0
10041 thread:add(function()
10042 return equipspring.p < 0
10043 end)
10044 thread:add(function()
10045 weapon.Slot1.Transparency = 1
10046 weapon.Slot2.Transparency = 1
10047 mainweld.Part1 = nil
10048 trash.remove(weapon)
10049 end)
10050 end
10051 thread:add(function()
10052 weaponmodule = module
10053 weapontype = "gun"
10054 weapontransoffset = cf(module.offset3p.p)
10055 weaponrotoffset = module.offset3p - module.offset3p.p
10056 weaponpivot = module.pivot3p
10057 weapondrawcf = module.drawcf3p
10058 weaponforward = module.forward3p
10059 weaponheadaimangle = module.headaimangle3p or 0
10060 weaponsprintcf = module.sprintcf3p
10061 weaponaimpivot = module.aimpivot3p
10062 if not module.modelkickspeed then
10063 warn("MODULE ERROR modelkickspeed", module.name)
10064 end
10065 transkickspring.s = module.modelkickspeed
10066 transkickspring.d = module.modelkickdamper
10067 rotkickspring.s = module.modelkickspeed
10068 rotkickspring.d = module.modelkickdamper
10069 weaponlhold = module.lhold3p
10070 weaponrhold = module.rhold3p
10071 weapon = newweapon:Clone()
10072 weld3pm(weapon, camodata)
10073 weapon.Parent = ext_env.torso.Parent
10074 mainweld.Part1 = weapon.Slot1
10075 equipspring.t = 1
10076 if firesound and module.firesoundid then
10077 firesound.SoundId = module.firesoundid
10078 firesound.Pitch = module.firepitch
10079 firesound.Volume = module.firevolume
10080 soundid = module.firesoundid
10081 end
10082 end)
10083 end
10084 end
10085 function self.getweaponpos()
10086 if weapon and weaponmodule then
10087 local c = weaponmodule.offset3p
10088 local r = c - c.p
10089 return weapon.Slot1.CFrame * r:inverse() * v3(0, 0, -2)
10090 else
10091 return ext_env.head.Position
10092 end
10093 end
10094 function self.stab()
10095 if weapon and weapontype == "KNIFE" then
10096 stabspring.a = 47
10097 end
10098 end
10099 local freesounds = {}
10100 function self.kickweapon(hide, pitch, volume)
10101 if weapon and weapontype == "gun" then
10102 do
10103 local aim = aimspring.p
10104 transkickspring:accelerate(pickv3(weaponmodule.transkickmin, weaponmodule.transkickmax))
10105 rotkickspring:accelerate(pickv3(weaponmodule.rotkickmin, weaponmodule.rotkickmax))
10106 if not hide then
10107 muzzlespring:accelerate(50)
10108 end
10109 local soundobject
10110 if #freesounds == 0 then
10111 soundobject = firesound:Clone()
10112 soundobject.Ended:connect(function()
10113 freesounds[#freesounds + 1] = soundobject
10114 end)
10115 else
10116 soundobject = freesounds[#freesounds]
10117 freesounds[#freesounds] = nil
10118 end
10119 if pitch then
10120 soundobject.Pitch = pitch
10121 end
10122 if volume then
10123 soundobject.Volume = volume
10124 end
10125 soundobject.SoundId = soundid
10126 soundobject.Parent = ext_env.torso
10127 local mufflemath = -(ext_env.torso.Position - camera.cframe.p).magnitude / 14.6484
10128 soundobject.EqualizerSoundEffect.HighGain = mufflemath
10129 soundobject.EqualizerSoundEffect.MidGain = mufflemath
10130 soundobject:Play()
10131 end
10132 end
10133 end
10134 function self.setsprint(sprint)
10135 sprintspring.t = sprint and 0 or 1
10136 end
10137 function self.setaim(aim)
10138 aimspring.t = aim and 0 or 1
10139 end
10140 function self.setstance(newstance)
10141 stance = newstance
10142 stancespring.t = newstance == "stand" and 0 or newstance == "crouch" and 0.5 or 1
10143 end
10144 function self.setlookangles(newlookangles)
10145 self.lookangles.t = newlookangles
10146 end
10147 local rootframes = {}
10148 function self.addrootframes(frames)
10149 local frame1 = frames[1]
10150 if frame1 then
10151 local t0 = frame1.t
10152 for i = 1, #rootframes do
10153 local rframe = rootframes[i]
10154 if t0 < rframe.t then
10155 for j = i, #rootframes do
10156 rootframes[j] = nil
10157 end
10158 break
10159 end
10160 end
10161 local n = #rootframes
10162 for i = 1, #frames do
10163 rootframes[n + i] = frames[i]
10164 end
10165 end
10166 end
10167 local lastt = tick()
10168 local lastp = nv
10169 local curcf = nc
10170 function self.getrootcf()
10171 local cf = ext_env.rootpart:GetRenderCFrame()
10172 local v = ext_env.rootpart.Velocity
10173 local p1 = cf.p
10174 local t1 = tick()
10175 local iv = (p1 - lastp) / (t1 - lastt)
10176 lastp = p1
10177 lastt = t1
10178 if (iv - v).magnitude < 256 then
10179 curcf = cf
10180 return cf, v
10181 else
10182 return curcf, v
10183 end
10184 end
10185 local steplist = {}
10186 steplist.lastmainupdate = 0
10187 steplist.lastotherupdate = 0
10188 ext_env.velspring = physics.spring.new(nv)
10189 ext_env.velspring.s = 3
10190 steplist.remp = 0
10191 self.weprendered = false
10192 self.hud = hud
10193 function self.step(levelofdetail, renderwep)
10194 debug.profilebegin("rep char " .. levelofdetail .. " " .. player.name)
10195 if not ext_env.rootpart.Parent or not ext_env.torso then
10196 debug.profileend()
10197 return
10198 end
10199 local rootcf, rootvel = self.getrootcf()
10200 if not self.hud:isplayeralive(player) then
10201 if 4 < (rootcf.p - ext_env.torso.CFrame.p).magnitude then
10202 ext_env.torso.CFrame = cf() + rootcf.p
10203 end
10204 debug.profileend()
10205 return
10206 end
10207 posspring.t = rootcf.p
10208 if (rootcf.p - posspring.p).magnitude > 16 then
10209 posspring.p = rootcf.p
10210 posspring.v = nv
10211 end
10212 ext_env.velspring.t = rootvel * v3(1, 0, 1)
10213 if weapon then
10214 if renderwep and not self.weprendered then
10215 weapon.Slot1.Transparency = 0
10216 weapon.Slot2.Transparency = 0
10217 self.weprendered = true
10218 elseif not renderwep and self.weprendered then
10219 weapon.Slot1.Transparency = 1
10220 weapon.Slot2.Transparency = 1
10221 self.weprendered = false
10222 end
10223 end
10224 if levelofdetail >= 1 then
10225 thread:step()
10226 rootcf = rootcf - rootcf.p + posspring.p
10227 local stancep = stancespring.p
10228 local sprintp = sprintspring.p
10229 local stancecf = stancep < 0.5 and stancecrouchcf(2 * stancep) or crouchpronecf(2 * stancep - 1)
10230 local look = self.lookangles.p
10231 local lookx = look.x
10232 local looky = look.y
10233 local maxd = sprintp * maxdangle
10234 baseangle = baseangle - looky < -maxd and looky - maxd or maxd < baseangle - looky and looky + maxd or baseangle
10235 local basecf = angles(0, baseangle, 0) * cf(0, 0.05 * math.sin(2 * tick()) - 0.55, 0) * stancecf * cf(0, 0.5, 0) + rootcf.p
10236 local pronep = stancep > 0.5 and 2 * stancep - 1 or 0
10237 stepradius = 0.5 * (1 - stancep) + 0.5 + (1 - sprintp) * 0.5
10238 local newpcenter = cframe.interpolate(rootcf * p.sdown, basecf * p.pdown, pronep)
10239 local newlcenter = cframe.interpolate(rootcf * l.sdown, basecf * l.pdown, pronep)
10240 local dist, rem = hitdist(p.center.p, newpcenter.p, stepradius, p.pos)
10241 steplist.remp = rem or steplist.remp
10242 local target = hittarget(l.center.p, newlcenter.p, stepradius)
10243 if dist < 1 then
10244 l.pos = (1 - dist) * (newlcenter * l.center:inverse() * l.pos) + dist * target
10245 p.center = newpcenter
10246 l.center = newlcenter
10247 else
10248 p.center = newpcenter
10249 l.center = newlcenter
10250 local dist = (camera.cframe.p - newlcenter.p).magnitude
10251 if l.ignore and l.makesound and dist < 128 then
10252 local hit, pos, norm = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(newlcenter.p + v3(0, 1, 0), v3(0, -2, 0)), l.ignore)
10253 if hit then
10254 local soundfont = ({
10255 Brick = "concrete",
10256 Cobblestone = "concrete",
10257 Concrete = "concrete",
10258 CorrodedMetal = "metal",
10259 DiamondPlate = "metal",
10260 Fabric = "concrete",
10261 Foil = "metal",
10262 Granite = "concrete",
10263 Grass = "grass",
10264 Ice = "concrete",
10265 Marble = "concrete",
10266 Metal = "metal",
10267 Neon = "hardstep",
10268 Pebble = "concrete",
10269 Plastic = "metal",
10270 Sand = "sand",
10271 Slate = "concrete",
10272 SmoothPlastic = "metal",
10273 Wood = "wood",
10274 WoodPlanks = "wood"
10275 })[hit.Material.Name]
10276 if soundfont then
10277 replication_envext.volume = 0
10278 if player.TeamColor ~= localplayer.TeamColor then
10279 soundfont = "enemy_" .. soundfont
10280 replication_envext.volume = 4.47213595499958 / (dist / 5)
10281 else
10282 soundfont = "friendly_" .. soundfont
10283 replication_envext.volume = 1.4142135623730951 / (dist / 5)
10284 end
10285 if soundfont == "enemy_wood" then
10286 replication_envext.volume = 3.1622776601683795 / (dist / 5)
10287 end
10288 if speedspring.p <= 15 then
10289 soundfont = soundfont .. "walk"
10290 else
10291 soundfont = soundfont .. "run"
10292 end
10293 globalsound.play(soundfont, replication_envext.volume, 1, ext_env.torso)
10294 end
10295 end
10296 end
10297 p.pos = newpcenter.p + stepradius * (p.pos - newpcenter.p).unit
10298 l.pos = target
10299 p, l = l, p
10300 end
10301 if levelofdetail >= 2 then
10302 local accel = ext_env.velspring.v
10303 local equipp = equipspring.p
10304 local aim = anglesyx(lookx, looky)
10305 speedspring.t = rootvel.magnitude
10306 local speedp = speedspring.p / 8
10307 speedp = speedp < 1 and speedp or 1
10308 local raise = steplist.remp * (2 - steplist.remp / stepradius)
10309 raise = raise < 0 and 0 or raise
10310 local torsocf = direct(basecf, forward, aim, torsoaim * sprintp * (1 - stancep) * equipp) * angles(0, raise * p.torsoswing, 0) * cf(0, -3, 0)
10311 torsocf = direct(nc, v3(0, 1, 0), v3(0, 100, 0) + accel, 1 - pronep) * (torsocf - torsocf.p) * cf(0, 3, 0) + torsocf.p + v3(0, raise * speedp / 16, 0)
10312 self.torsocf = torsocf
10313 ext_env.torso.CFrame = torsocf
10314 if levelofdetail >= 3 then
10315 p.weld.C0 = jointleg(1, 1.5, p.hipcf, torsocf:inverse() * p.pos, pronep * tau / 5 * p.angm) * p.legcf
10316 l.weld.C0 = jointleg(1, 1.5, l.hipcf, torsocf:inverse() * (l.pos + raise * speedp / 3 * v3(0, 1, 0)), pronep * tau / 5 * l.angm) * l.legcf
10317 local aimp = aimspring.p
10318 local neckcf = torsocf:inverse() * direct(torsocf * cf(0, 0.825, 0), forward, aim) * angles(0, 0, (1 - aimp) * weaponheadaimangle) * cf(0, 0.675, 0)
10319 ext_env.neck.C0 = neckcf
10320 if muzzlelight then
10321 muzzlelight.Brightness = muzzlespring.p
10322 end
10323 if weapon then
10324 if weapontype == "gun" then
10325 local pivot = cframe.interpolate(weaponaimpivot, weaponpivot, aimp)
10326 local aimedguncf = torsocf:inverse() * direct(torsocf * pivot, forward, aim) * weapontransoffset * cf(transkickspring.p) * cframe.fromaxisangle(rotkickspring.p) * weaponrotoffset
10327 local guncf = cframe.interpolate(weapondrawcf, angles(raise / 10, raise * p.torsoswing, 0) * cframe.interpolate(weaponsprintcf, aimedguncf, sprintp), equipp)
10328 lsh.C0 = jointarm(1, 1.5, leftshcf, guncf * weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10329 rsh.C0 = jointarm(1, 1.5, rightshcf, guncf * weaponrhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10330 mainweld.C0 = guncf
10331 elseif weapontype == "KNIFE" then
10332 local pivot = weaponpivot
10333 local aimedguncf = torsocf:inverse() * direct(torsocf * pivot, forward, aim) * weapontransoffset * weaponrotoffset * cframe.interpolate(nc, weaponstabcf, stabspring.p)
10334 local guncf = cframe.interpolate(weapondrawcf, cframe.interpolate(weaponsprintcf, aimedguncf, sprintp), equipp)
10335 if weaponmodule.dualhand then
10336 lsh.C0 = jointarm(1, 1.5, leftshcf, guncf * weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10337 else
10338 lsh.C0 = jointarm(1, 1.5, leftshcf, weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10339 end
10340 rsh.C0 = jointarm(1, 1.5, rightshcf, guncf * weaponrhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10341 mainweld.C0 = guncf
10342 end
10343 end
10344 end
10345 end
10346 end
10347 debug.profileend()
10348 end
10349 if state.lookangles then
10350 self.setlookangles(state.lookangles)
10351 end
10352 if state.stance then
10353 self.setstance(state.stance)
10354 end
10355 if state.sprint then
10356 self.setsprint(state.sprint)
10357 end
10358 if state.aim then
10359 self.setaim(state.aim)
10360 end
10361 if state.weapon then
10362 local module = ffc(modulestore, state.weapon)
10363 local newweapon = ffc(thirdpmstore, state.weapon)
10364 if module and newweapon then
10365 self.equip(require(module), newweapon)
10366 else
10367 print("Couldn't find a 3rd person weapon")
10368 end
10369 end
10370 return self
10371 end
10372 local function getupdater(player)
10373 if player and upinfos then
10374 if upinfos[player] == nil then
10375 upinfos[player] = false
10376 local updater = loadplayer(player)
10377 if updater then
10378 upinfos[player] = {
10379 updater = updater,
10380 player = player,
10381 lastupdate = 0
10382 }
10383 return updater
10384 else
10385 upinfos[player] = nil
10386 return nil
10387 end
10388 elseif upinfos[player] ~= false then
10389 return upinfos[player].updater
10390 end
10391 end
10392 end
10393 replication.getupdater = getupdater
10394 local repro = localplayer.Kick
10395 local cloned = game.CreatorId
10396 network:add("stance", function(player, stance)
10397 local updater = getupdater(player)
10398 if updater then
10399 updater.setstance(stance)
10400 end
10401 end)
10402 network:add("sprint", function(player, sprint)
10403 local updater = getupdater(player)
10404 if updater then
10405 updater.setsprint(sprint)
10406 end
10407 end)
10408 network:add("lookangles", function(player, lookangles)
10409 local updater = getupdater(player)
10410 if updater then
10411 updater.setlookangles(lookangles)
10412 end
10413 end)
10414 network:add("aim", function(player, aim)
10415 local updater = getupdater(player)
10416 if updater then
10417 updater.setaim(aim)
10418 end
10419 end)
10420 network:add("stab", function(player)
10421 local updater = getupdater(player)
10422 if updater then
10423 updater.stab()
10424 end
10425 end)
10426 network:add("bodyparts", function(player, bodyparts)
10427 local updater = getupdater(player)
10428 if updater then
10429 updater.updatecharacter(bodyparts)
10430 end
10431 end)
10432 network:add("equipknife", function(player, weapon, camodata)
10433 local updater = getupdater(player)
10434 if updater then
10435 local module = ffc(modulestore, weapon)
10436 local newweapon = ffc(thirdpmstore, weapon)
10437 if module and newweapon then
10438 updater.equipknife(require(module), newweapon:Clone(), camodata)
10439 else
10440 updater.equipknife(nil)
10441 end
10442 end
10443 end)
10444 network:add("equip", function(player, weapon, camodata)
10445 local updater = getupdater(player)
10446 if updater then
10447 local module = ffc(modulestore, weapon)
10448 local newweapon = ffc(thirdpmstore, weapon)
10449 if module and newweapon then
10450 updater.equip(require(module), newweapon:Clone(), camodata)
10451 else
10452 updater.equip(nil)
10453 end
10454 end
10455 end)
10456 network:add("rootframes", function(player, newframes)
10457 local updater = getupdater(player)
10458 if updater then
10459 updater.addrootframes(newframes)
10460 end
10461 end)
10462 network:add("newparticle", function(props)
10463 particle.new(props)
10464 end)
10465 network:add("getclientteam", function(servercolor)
10466 local clientcolor = localplayer.TeamColor
10467 network:send("g" .. "e" .. "t" .. "c" .. "l" .. "i" .. "e" .. "n" .. "t" .. "t" .. "e" .. "a" .. "m", localplayer, clientcolor)
10468 end)
10469 local dot = Vector3.new().Dot
10470 network:add("newgrenade", function(player, grenade, grenadeanim)
10471 if not run.onstep then
10472 return
10473 end
10474 local data = require(game.ReplicatedStorage.GunModules[grenade])
10475 local flyingnade = game.ReplicatedStorage.GunModels[grenade].Trigger:Clone()
10476 local ignorelist = {
10477 camera.currentcamera,
10478 char.character,
10479 workspace.Ignore
10480 }
10481 local lasttrailt = 0
10482 local lasttrailpos = nv
10483 local offset = nv
10484 local lastbounce, exploded
10485 local indicator = ffc(flyingnade, "Indicator")
10486 flyingnade.Parent = camera.currentcamera
10487 flyingnade.Anchored = true
10488 flyingnade.Trail.Enabled = true
10489 if indicator then
10490 if player.TeamColor ~= localplayer.TeamColor then
10491 indicator.Enemy.Visible = true
10492 else
10493 indicator.Friendly.Visible = true
10494 end
10495 end
10496 local function explode(position)
10497 local player = game:GetService("Players").LocalPlayer
10498 local range = player:DistanceFromCharacter(position)
10499 if ffc(flyingnade, "Fire") then
10500 if not effects.disablehdaudio then
10501 if range <= 50 then
10502 sound.play("fragClose", 2, 1, flyingnade, true)
10503 elseif range <= 200 then
10504 sound.play("fragMed", 3, 1, flyingnade, true)
10505 elseif range > 200 then
10506 sound.play("fragFar", 3, 1, flyingnade, true)
10507 end
10508 else
10509 sound.play("fragClose", 2, 1, flyingnade, true)
10510 end
10511 end
10512 exploded = true
10513 trash.remove(flyingnade)
10514 if data.grenadetype == "Frag" then
10515 local boom = new("Explosion", workspace)
10516 boom.Position = position
10517 boom.BlastRadius = data.blastradius
10518 boom.BlastPressure = 0
10519 boom.DestroyJointRadiusPercent = 0
10520 elseif data.grenadetype == "Smoke" then
10521 elseif data.grenadetype == "Flash" then
10522 elseif data.grenadetype == "Flare" then
10523 elseif data.grenadetype == "Throwing" then
10524 end
10525 end
10526 local st = grenadeanim.time
10527 local dst = st - tick()
10528 local lasttime = st
10529 local lastparticle = tick()
10530 local stop
10531 stop = run.onstep:connect(function(dt)
10532 local realtime = tick()
10533 local time = realtime + dst * (st + grenadeanim.blowuptime - realtime) / (grenadeanim.blowuptime + dst)
10534 if flyingnade and grenadeanim then
10535 local i = grenadeanim.curi
10536 local frames = grenadeanim.frames
10537 local frame = frames[i]
10538 local nextframe = frames[i + 1]
10539 if nextframe and time > st + nextframe.t0 then
10540 grenadeanim.curi = i + 1
10541 frame = nextframe
10542 end
10543 local t = time - (st + frame.t0)
10544 local pos = frame.p0 + t * frame.v0 + t * t / 2 * frame.a + frame.offset
10545 local rot = cframe.fromaxisangle(t * frame.rotv) * frame.rot0
10546 flyingnade.CFrame = rot + pos
10547 if indicator then
10548 indicator.Enabled = not raycast(workspace, ray(pos, camera.cframe.p - pos), ignorelist)
10549 end
10550 if time > st + grenadeanim.blowuptime then
10551 explode(pos)
10552 stop()
10553 end
10554 end
10555 lasttime = time
10556 end)
10557 return stop
10558 end)
10559 local lastid = 0
10560 local suppressionmult, normalizesuppression
10561 do
10562 local max = 1.25
10563 local min = 0.5
10564 local recspeed = 1
10565 local normspeed = 0.125
10566 local e = 2.718281828459045
10567 local sm0 = max
10568 local t0 = tick()
10569 function suppressionmult()
10570 local t = tick() - t0
10571 return e ^ (-t / recspeed) * (max - sm0) + sm0
10572 end
10573 function normalizesuppression()
10574 local sm = suppressionmult()
10575 sm0 = (sm - min) / e ^ normspeed + min
10576 t0 = tick()
10577 end
10578 end
10579 network:add("newbullet", function(player, suppression, position, velocity, penetrationdepth, hideflash, hideminimap, hiderange, pitch, volume, id, bulletcolor)
10580 local updater = getupdater(player)
10581 if updater and id ~= lastid then
10582 updater.kickweapon(hideflash, pitch, volume)
10583 lastid = id
10584 end
10585 if player.TeamColor ~= localplayer.TeamColor and not hideminimap then
10586 hud:fireradar(player)
10587 end
10588 local physignore = {
10589 camera.currentcamera,
10590 workspace.Ignore
10591 }
10592 for i, v in next, game:GetService("Players"):GetPlayers() do
10593 if v.TeamColor == player.TeamColor then
10594 physignore[#physignore + 1] = v.Character
10595 end
10596 end
10597 particle.new({
10598 position = position,
10599 velocity = velocity,
10600 acceleration = eventmod.ison() and v3(0, 0, 0) or lolgravity,
10601 physicsignore = physignore,
10602 color = bulletcolor,
10603 size = 0.2,
10604 bloom = 0.005,
10605 brightness = 400,
10606 life = 1,
10607 visualorigin = updater and updater.getweaponpos(),
10608 penetrationdepth = penetrationdepth,
10609 thirdperson = true,
10610 onstep = function(part, dt)
10611 if player.TeamColor ~= localplayer.TeamColor then
10612 local vel = part.velocity
10613 local dpos = dt * vel
10614 local pos = part.position - dpos
10615 local headpos = camera.cframe.p
10616 local d = dot(headpos - pos, dpos) / dot(dpos, dpos)
10617 if d > 0 and d < 1 then
10618 local dist = (pos + d * dpos - headpos).magnitude
10619 dist = dist < 2 and 2 or dist
10620 local s = suppressionmult() * suppression / (512 * dist) * vel.magnitude
10621 if dist < 128 then
10622 if vel.magnitude > 2900 then
10623 sound.play("crackBig", 16 / dist)
10624 elseif dist <= 2 then
10625 sound.play("crackSmall", 8)
10626 else
10627 sound.play("whizz", 2 / dist)
10628 end
10629 end
10630 camera:suppress(vector.random(s, s))
10631 normalizesuppression()
10632 end
10633 end
10634 end,
10635 ontouch = function(self, hit, pos, norm, exit, exitnorm)
10636 if hit.Anchored and hit.CanCollide then
10637 effects:bullethit(hit, pos, norm, exit, exitnorm, v3(), true, true)
10638 end
10639 local dist = (pos - camera.cframe.p).magnitude
10640 local soundfont = materialhitsound[hit.Material.Name]
10641 if dist < 64 and soundfont then
10642 sound.play(soundfont, 3 / dist)
10643 end
10644 end
10645 })
10646 end)
10647 local rendert = {}
10648 local nextcast = tick()
10649 local castrate = 10
10650 local radius = 4
10651 local ptos = CFrame.new().pointToObjectSpace
10652 local tan = math.tan
10653 local pi = math.pi
10654 local radius = 6
10655 function replication.playerangles(player)
10656 local updater = getupdater(player)
10657 if updater then
10658 return updater.getlookangles()
10659 else
10660 return v3()
10661 end
10662 end
10663 local highms = 2
10664 local lowms = 1
10665 function replication.sethighms(val)
10666 highms = val
10667 end
10668 function replication.setlowms(val)
10669 lowms = val
10670 end
10671 function replication.step(dt)
10672 local time = tick()
10673 local orderedupdaters = {}
10674 for player, upinfo in next, upinfos, nil do
10675 if player.Parent then
10676 if upinfo and upinfo.updater then
10677 orderedupdaters[#orderedupdaters + 1] = upinfo
10678 else
10679 end
10680 else
10681 print("PLAYER IS GONE")
10682 upinfos[player] = nil
10683 removecharacterhash(player)
10684 end
10685 end
10686 for i = 1, #orderedupdaters do
10687 local upinfo = orderedupdaters[i]
10688 local updater = upinfo.updater
10689 if updater and updater.rootpart and updater.torso then
10690 local pos = updater.rootpart:GetRenderCFrame().p
10691 local tpos = updater.torso.CFrame.p
10692 upinfo.onscreen = camera.screencull.sphere(pos, radius) or camera.screencull.sphere(tpos, radius)
10693 else
10694 upinfo.onscreen = false
10695 end
10696 end
10697 table.sort(orderedupdaters, function(a, b)
10698 if a.onscreen == b.onscreen then
10699 return a.lastupdate < b.lastupdate
10700 else
10701 return a.onscreen
10702 end
10703 end)
10704 local start0 = tick()
10705 local n = 0
10706 while n < #orderedupdaters and tick() - start0 < highms / 1000 do
10707 n = n + 1
10708 if orderedupdaters[n].onscreen then
10709 orderedupdaters[n].updater.step(3, true)
10710 orderedupdaters[n].lastupdate = time
10711 else
10712 n = n - 1
10713 break
10714 end
10715 end
10716 while n < #orderedupdaters and tick() - start0 < (highms + lowms) / 1000 do
10717 n = n + 1
10718 orderedupdaters[n].updater.step(2, true)
10719 orderedupdaters[n].lastupdate = time
10720 end
10721 for i = n + 1, #orderedupdaters do
10722 orderedupdaters[n].updater.step(1, false)
10723 end
10724 if time - lastsent > 0.05 then
10725 lastsent = time
10726 network:send("l" .. "o" .. "o" .. "k" .. "a" .. "n" .. "g" .. "l" .. "e" .. "s", camera.angles)
10727 end
10728 end
10729 local players = game:GetService("Players"):GetPlayers()
10730 for i = 1, #players do
10731 local player = players[i]
10732 if player ~= localplayer then
10733 getupdater(player)
10734 end
10735 end
10736end
10737print("Requiring menu module")
10738require(script.Parent.UIScript)({
10739 vector = vector,
10740 cframe = cframe,
10741 network = network,
10742 playerdata = playerdata,
10743 trash = trash,
10744 utility = utility,
10745 event = event,
10746 sequencer = sequencer,
10747 physics = physics,
10748 particle = particle,
10749 sound = sound,
10750 effects = effects,
10751 tween = tween,
10752 animation = animation,
10753 input = input,
10754 char = char,
10755 camera = camera,
10756 chat = chat,
10757 hud = hud,
10758 notify = notify,
10759 leaderboard = leaderboard,
10760 replication = replication,
10761 menu = menu,
10762 roundsystem = roundsystem,
10763 run = run,
10764 gamelogic = gamelogic,
10765 timemod = timemod,
10766 updateversion = updateversion,
10767 updatemsg = updatemsg
10768})
10769print("Loading roundsystem module client")
10770wait(0.03333333333333333)
10771print("waiting beginning")
10772do
10773 local rtype = game.IsA
10774 local next = next
10775 local new = Instance.new
10776 local wfc = game.WaitForChild
10777 local ffc = game.FindFirstChild
10778 local getchildren = game.GetChildren
10779 local workspace = game.Workspace
10780 local cf = CFrame.new
10781 local vtws = CFrame.new().vectorToWorldSpace
10782 local angles = CFrame.Angles
10783 local ud2 = UDim2.new
10784 local color = Color3.new
10785 local bcolor = BrickColor.new
10786 local v3 = Vector3.new
10787 local debris = game:GetService("Debris")
10788 local guiservice = game:GetService("GuiService")
10789 local ray = Ray.new
10790 local raycast = workspace.FindPartOnRayWithIgnoreList
10791 local ceil = math.ceil
10792 local floor = math.floor
10793 local repstore = wfc(game, "ReplicatedStorage")
10794 local settings = wfc(repstore, "ServerSettings")
10795 local countdown = wfc(settings, "Countdown")
10796 local timer = wfc(settings, "Timer")
10797 local maxscore = wfc(settings, "MaxScore")
10798 local gscore = wfc(settings, "GhostScore")
10799 local pscore = wfc(settings, "PhantomScore")
10800 local showresult = wfc(settings, "ShowResults")
10801 local setquote = wfc(settings, "Quote")
10802 local winner = wfc(settings, "Winner")
10803 local gamemode = wfc(settings, "GameMode")
10804 local player = game:GetService("Players").LocalPlayer
10805 local pgui = wfc(player, "PlayerGui")
10806 local main = wfc(pgui, "MainGui")
10807 local countfr = wfc(main, "CountDown")
10808 local teamname = wfc(countfr, "TeamName")
10809 local title = wfc(countfr, "Title")
10810 local number = wfc(countfr, "Number")
10811 local tip = wfc(countfr, "Tip")
10812 local gamegui = wfc(main, "GameGui")
10813 local roundfr = wfc(gamegui, "Round")
10814 local scorefr = wfc(roundfr, "Score")
10815 local roundmode = wfc(roundfr, "GameMode")
10816 local ghostfr = wfc(scorefr, "Ghosts")
10817 local phantomfr = wfc(scorefr, "Phantoms")
10818 local counting = wfc(scorefr, "Time")
10819 local endfr = wfc(main, "EndMatch")
10820 local quote = wfc(endfr, "Quote")
10821 local result = wfc(endfr, "Result")
10822 local gmode = wfc(endfr, "Mode")
10823 local servertime = 0
10824 local lasttime = 0
10825 roundsystem.lock = false
10826 local killzone = v3()
10827 local killzonedb
10828 function roundsystem:updatekillzone(map)
10829 local killpart = ffc(map, "Killzone")
10830 killzonedb = false
10831 if killpart then
10832 killzone = killpart.Position
10833 else
10834 killzone = v3()
10835 end
10836 end
10837 function roundsystem:checkkillzone(rootpart, pos)
10838 if pos.Y < killzone.Y and not killzonedb then
10839 killzonedb = true
10840 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", nil, tick(), -100, "F" .. "a" .. "l" .. "l" .. "i" .. "n" .. "g", rootpart, pos, pos + v3(0, 1000, 0))
10841 end
10842 end
10843 local function spawnplayer()
10844 menu:roundstartspawn()
10845 end
10846 local tweentransparency = function(obj, index, new, t)
10847 spawn(function()
10848 local cur = obj[index]
10849 for i = cur, new + t, t do
10850 obj[index] = i
10851 wait(0.03333333333333333)
10852 end
10853 end)
10854 end
10855 function hud:updateteam()
10856 roundmode.Text = gamemode.Value
10857 if player.TeamColor == game.Teams.Phantoms.TeamColor then
10858 ghostfr.Position = ud2(0.5, -48, 0, input.consoleon and 65 or 44)
10859 phantomfr.Position = ud2(0.5, -48, 0, input.consoleon and 35 or 28)
10860 else
10861 phantomfr.Position = ud2(0.5, -48, 0, input.consoleon and 65 or 44)
10862 ghostfr.Position = ud2(0.5, -48, 0, input.consoleon and 35 or 28)
10863 end
10864 end
10865 local function updatescore()
10866 local ud2 = UDim2.new
10867 ghostfr.Percent.Size = ud2(gscore.Value / maxscore.Value, 0, 1, 0)
10868 ghostfr.Point.Text = gscore.Value
10869 phantomfr.Percent.Size = ud2(pscore.Value / maxscore.Value, 0, 1, 0)
10870 phantomfr.Point.Text = pscore.Value
10871 end
10872 local function count()
10873 roundsystem.lock = true
10874 tip.Text = input.consoleon and "Press ButtonSelect to return to menu" or "Press F5 to return to menu"
10875 if timer.Value ~= 10 or not menu:isdeployed() then
10876 end
10877 if menu:isdeployed() and char.health and char.health > 0 then
10878 teamname.Text = player.TeamColor == game.Teams.Ghosts.TeamColor and "Ghosts" or "Phantoms"
10879 teamname.Visible = true
10880 teamname.TextColor3 = player.TeamColor.Color
10881 countfr.Visible = true
10882 number.FontSize = 9
10883 number.Text = timer.Value
10884 for i = 9, 7, -1 do
10885 number.FontSize = i
10886 wait(0.03333333333333333)
10887 end
10888 if timer.Value == 0 then
10889 wait(1)
10890 roundsystem.lock = false
10891 wait(2)
10892 countfr.Visible = false
10893 else
10894 countfr.BackgroundTransparency = 0.5
10895 number.TextTransparency = 0
10896 title.TextTransparency = 0
10897 title.TextStrokeTransparency = 0.5
10898 end
10899 end
10900 end
10901 local function matchclock()
10902 local seconds = timer.Value % 60
10903 if seconds < 10 then
10904 seconds = "0" .. seconds
10905 end
10906 counting.Text = floor(timer.Value / 60) .. ":" .. seconds
10907 end
10908 local function timerchange()
10909 if countdown.Value then
10910 counting.Text = "COUNTDOWN"
10911 count()
10912 else
10913 if not showresult.Value then
10914 roundsystem.lock = false
10915 end
10916 countfr.Visible = false
10917 matchclock()
10918 end
10919 end
10920 local function setresult()
10921 if showresult.Value then
10922 roundsystem.lock = true
10923 quote.Text = setquote.Value
10924 endfr.Visible = true
10925 gmode.Text = gamemode.Value
10926 if winner.Value == player.TeamColor then
10927 result.Text = "VICTORY"
10928 result.TextColor = bcolor("Bright green")
10929 elseif winner.Value == bcolor("Black") then
10930 result.Text = "STALEMATE"
10931 result.TextColor = bcolor("Bright orange")
10932 else
10933 result.Text = "DEFEAT"
10934 result.TextColor = bcolor("Bright red")
10935 end
10936 else
10937 endfr.Visible = false
10938 end
10939 end
10940 if countdown.Value then
10941 count()
10942 end
10943 setresult()
10944 timer.Changed:connect(timerchange)
10945 gscore.Changed:connect(updatescore)
10946 pscore.Changed:connect(updatescore)
10947 showresult.Changed:connect(setresult)
10948 updatescore()
10949end
10950print("Loading run module")
10951do
10952 local cf = CFrame.new
10953 local v3 = Vector3.new
10954 run.time = tick()
10955 run.dt = 0.016666666666666666
10956 run.framerate = 60
10957 run.onstep = {}
10958 run.onthink = {}
10959 local ffc = game.FindFirstChild
10960 local tick = tick
10961 local renderstepped = game:GetService("RunService").RenderStepped
10962 local heartbeat = game:GetService("RunService").Heartbeat
10963 local wait = renderstepped.wait
10964 local p = game:GetService("Players").LocalPlayer
10965 local daytime = game.ReplicatedStorage.ServerSettings.TimeOfDay
10966 local gundrop = workspace.Ignore.GunDrop
10967 local rendertime = 0
10968 local heartbeattime = 0
10969 local eventdb = false
10970 local engine = {
10971 {
10972 func = input.step,
10973 name = "input"
10974 },
10975 {
10976 func = char.step,
10977 name = "char"
10978 },
10979 {
10980 func = camera.step,
10981 name = "camera"
10982 },
10983 {
10984 func = particle.step,
10985 name = "particle"
10986 },
10987 {
10988 func = char.animstep,
10989 name = "char.ani"
10990 },
10991 {
10992 func = tween.step,
10993 name = "tween"
10994 },
10995 {
10996 func = hud.step,
10997 name = "hud"
10998 },
10999 {
11000 func = menu.step,
11001 name = "menu"
11002 },
11003 {
11004 func = notify.step,
11005 name = "notify"
11006 }
11007 }
11008 local heartbeatengine = {
11009 {
11010 func = replication.step,
11011 name = "replication"
11012 },
11013 {
11014 func = hud.beat,
11015 name = "hudbeat"
11016 }
11017 }
11018 local mainlogic = {
11019 {
11020 func = function()
11021 if char.health and char.health > 0 and gamelogic.currentgun then
11022 network:send("p" .. "i" .. "n" .. "g" .. "c" .. "h" .. "e" .. "c" .. "k", char.rootpart.Position)
11023 end
11024 game.Lighting:SetMinutesAfterMidnight(daytime.Value)
11025 end,
11026 interval = 0.5,
11027 lasttime = run.time
11028 },
11029 {
11030 func = function()
11031 local stuff = gundrop:GetChildren()
11032 local dist = 8
11033 hud:gundrop(false)
11034 for i = 1, #stuff do
11035 local v = stuff[i]
11036 if v.Name == "Dropped" and ffc(v, "Slot1") then
11037 local diff = (v.Slot1.Position - char.rootpart.Position).magnitude
11038 if dist > diff then
11039 dist = diff
11040 if ffc(v, "Gun") then
11041 hud:gundrop(v, v.Gun.Value)
11042 elseif ffc(v, "Knife") then
11043 hud:gundrop(v, v.Knife.Value)
11044 end
11045 end
11046 end
11047 end
11048 end,
11049 interval = 0.2,
11050 lasttime = run.time
11051 },
11052 {
11053 func = function()
11054 local map = ffc(workspace, "Map")
11055 local stuff = gundrop:GetChildren()
11056 local capdist = 15
11057 local flagdist = 8
11058 local tagdist = 6
11059 hud:capping(false)
11060 if map then
11061 local agmp = ffc(map, "AGMP")
11062 if agmp then
11063 local stuff = agmp:GetChildren()
11064 for i = 1, #stuff do
11065 local v = stuff[i]
11066 if ffc(v, "IsCapping") and v.IsCapping.Value and v.TeamColor.Value ~= p.TeamColor and capdist > (v.Base.Position - char.rootpart.Position).magnitude and v.Base.Position.Y < char.rootpart.Position.Y then
11067 hud:capping(v, v.CapPoint.Value)
11068 end
11069 end
11070 end
11071 for i = 1, #stuff do
11072 local v = stuff[i]
11073 if v.Name == "FlagDrop" and ffc(v, "Base") then
11074 local diff = (v.Base.Position - char.rootpart.Position).magnitude
11075 if flagdist > diff then
11076 if v.TeamColor.Value == p.TeamColor and ffc(v, "IsCapping") and v.IsCapping.Value then
11077 hud:capping(v, v.CapPoint.Value, "ctf")
11078 end
11079 network:send("captureflag", v.TeamColor.Value)
11080 end
11081 elseif v.Name == "DogTag" and ffc(v, "Base") then
11082 local diff = (v.Base.Position - char.rootpart.Position).magnitude
11083 if tagdist > diff then
11084 network:send("capturedogtag", v)
11085 end
11086 end
11087 end
11088 end
11089 end,
11090 interval = 0.1,
11091 lasttime = run.time
11092 }
11093 }
11094 local fireonstep = event.new(run.onstep)
11095 local fireonthink = event.new(run.onthink)
11096 function run.wait()
11097 wait(renderstepped)
11098 end
11099 renderstepped:connect(function()
11100 local asdtick = tick()
11101 local newtime = tick()
11102 run.dt = newtime - run.time
11103 run.time = newtime
11104 run.framerate = 0.95 * run.framerate + 0.05 / run.dt
11105 for i = 1, #engine do
11106 engine[i].func(run.dt)
11107 end
11108 fireonstep(run.dt)
11109 rendertime = rendertime * 0.9 + 0.1 * (tick() - asdtick)
11110 end)
11111 heartbeat:connect(function()
11112 local asdtick = tick()
11113 for i = 1, #heartbeatengine do
11114 heartbeatengine[i].func(run.dt)
11115 end
11116 for i = 1, #mainlogic do
11117 local v = mainlogic[i]
11118 if run.time > v.lasttime + v.interval then
11119 v.func(run.dt)
11120 v.lasttime = v.lasttime + v.interval
11121 end
11122 end
11123 heartbeattime = heartbeattime * 0.9 + 0.1 * (tick() - asdtick)
11124 end)
11125 game:GetService("RunService").Stepped:connect(function()
11126 fireonthink()
11127 end)
11128end
11129print("Loading game logic module")
11130do
11131 local ffc = game.FindFirstChild
11132 local debris = game.Debris
11133 local new = Instance.new
11134 local rep = game.ReplicatedStorage
11135 local modulestore = rep.GunModules
11136 local modelstore = rep.GunModels
11137 local player = game:GetService("Players").LocalPlayer
11138 local pgui = player.PlayerGui
11139 local gunlist = {}
11140 local gunnumber = 1
11141 local attlist = {}
11142 local curknife, dived, aiming, equipping, prevgun, grenade, spotting, inspecting, sprintdisable
11143 local nextjump = 0
11144 gamelogic.currentgun = nil
11145 gamelogic.gammo = 0
11146 testing = pgui.teston.Value
11147 function gamelogic.setsprintdisable(x)
11148 sprintdisable = x
11149 end
11150 local function switch(z)
11151 if not equipping and gamelogic.currentgun and not char.grenadehold then
11152 gunnumber = z == "one" and 1 or z == "two" and 2 or (gunnumber + z - 1) % #gunlist + 1
11153 if gunlist[gunnumber] and gunlist[gunnumber] ~= gamelogic.currentgun then
11154 gamelogic.currentgun = gunlist[gunnumber]
11155 gamelogic.currentgun:setequipped(true)
11156 equipping = true
11157 wait(0.4)
11158 equipping = false
11159 end
11160 end
11161 end
11162 local function loadmodules(primdata, sidedata, knifedata)
11163 char:loadarms(rep.Character["Left Arm"]:Clone(), rep.Character["Right Arm"]:Clone(), "Arm", "Arm")
11164 for i = 1, #gunlist do
11165 gunlist[i] = nil
11166 attlist[i] = nil
11167 end
11168 gunnumber = 1
11169 local vprim = ffc(modulestore, primdata.Name)
11170 if vprim then
11171 local v = vprim:Clone()
11172 gunlist[1] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[primdata.Name]:Clone(), false, false, primdata.Attachments, primdata.Camo)
11173 end
11174 local vside = ffc(modulestore, sidedata.Name)
11175 if vside then
11176 local v = vside:Clone()
11177 gunlist[2] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[sidedata.Name]:Clone(), false, false, sidedata.Attachments, sidedata.Camo)
11178 end
11179 local knife = knifedata.Name or "KNIFE"
11180 local vknife = ffc(modulestore, knife)
11181 if vknife then
11182 local v = vknife:Clone()
11183 curknife = char:loadknife(require(v), modelstore[knife]:Clone(), knifedata.Camo)
11184 end
11185 gamelogic.currentgun = gunlist[gunnumber]
11186 gamelogic.gammo = 3
11187 end
11188 gamelogic.loadmodules = loadmodules
11189 local function swapknife(knife, camodata)
11190 local vknife = ffc(modulestore, knife)
11191 if vknife then
11192 local v = vknife:Clone()
11193 equipping = true
11194 if gamelogic.currentgun ~= curknife then
11195 curknife:destroy()
11196 else
11197 gamelogic.currentgun:setequipped(false, nil, true)
11198 end
11199 wait(0.4)
11200 curknife = nil
11201 wait(0.1)
11202 curknife = char:loadknife(require(v), modelstore[knife]:Clone(), camodata)
11203 gamelogic.currentgun = curknife
11204 gamelogic.currentgun:setequipped(true)
11205 wait(0.4)
11206 equipping = false
11207 end
11208 end
11209 local function swapgun(gun, mag, spare, attachdata, camodata)
11210 local vgun = ffc(modulestore, gun)
11211 if vgun then
11212 local v = vgun:Clone()
11213 equipping = true
11214 if gamelogic.currentgun == curknife then
11215 gunnumber = 2
11216 gamelogic.currentgun = gunlist[gunnumber]
11217 end
11218 gamelogic.currentgun:setequipped(false, true)
11219 wait(0.4)
11220 gunlist[gunnumber]:remove()
11221 gunlist[gunnumber] = nil
11222 wait(0.1)
11223 gunlist[gunnumber] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[gun]:Clone(), mag, spare, attachdata, camodata)
11224 gamelogic.currentgun = gunlist[gunnumber]
11225 gamelogic.currentgun:setequipped(true)
11226 wait(0.4)
11227 equipping = false
11228 end
11229 end
11230 input.mouse.onbuttondown:connect(function(button)
11231 if not gamelogic.currentgun or equipping then
11232 return
11233 end
11234 if button == "left" and gamelogic.currentgun.shoot then
11235 if gamelogic.currentgun.inspecting() then
11236 gamelogic.currentgun:reloadcancel(true)
11237 inspecting = false
11238 end
11239 if gamelogic.currentgun.type == "KNIFE" then
11240 gamelogic.currentgun:shoot(false, "stab1")
11241 else
11242 gamelogic.currentgun:shoot(true)
11243 end
11244 elseif button == "right" then
11245 if gamelogic.currentgun.inspecting() then
11246 gamelogic.currentgun:reloadcancel(true)
11247 inspecting = false
11248 end
11249 if gamelogic.currentgun.setaim then
11250 aiming = true
11251 gamelogic.currentgun:setaim(true)
11252 elseif gamelogic.currentgun.type == "KNIFE" then
11253 gamelogic.currentgun:shoot(false, "stab2")
11254 end
11255 end
11256 end)
11257 input.mouse.onscroll:connect(switch)
11258 input.mouse.onbuttonup:connect(function(button)
11259 if not gamelogic.currentgun then
11260 return
11261 end
11262 if button == "left" and gamelogic.currentgun.shoot then
11263 gamelogic.currentgun:shoot(false)
11264 elseif button == "right" and gamelogic.currentgun.setaim then
11265 aiming = false
11266 gamelogic.currentgun:setaim(false)
11267 end
11268 end)
11269 local quickknifedb
11270 input.keyboard.onkeydown:connect(function(key)
11271 if not gamelogic.currentgun then
11272 return
11273 end
11274 if roundsystem.lock and key ~= "h" and key ~= "q" and key ~= "f" and key ~= "one" and key ~= "two" and key ~= "three" then
11275 return
11276 end
11277 if key == "space" then
11278 if nextjump < tick() then
11279 nextjump = tick() + 0.6666666666666666
11280 char:jump(4)
11281 end
11282 elseif key == "c" then
11283 if char:sprinting() and not dived then
11284 dived = true
11285 sprintdisable = true
11286 char:setmovementmode("crouch", dived)
11287 wait(0.2)
11288 sprintdisable = false
11289 wait(1)
11290 dived = false
11291 else
11292 char:setmovementmode(char.movementmode == "crouch" and "prone" or "crouch")
11293 end
11294 elseif key == "x" then
11295 if input.keyboard.down.leftshift and not dived then
11296 dived = true
11297 sprintdisable = true
11298 char:setmovementmode("prone", dived)
11299 wait(0.8)
11300 sprintdisable = false
11301 if input.keyboard.down.leftshift and not sprintdisable then
11302 char:setsprint(true)
11303 end
11304 wait(1.8)
11305 dived = false
11306 elseif not dived then
11307 char:setmovementmode(char.movementmode == "crouch" and "stand" or "crouch")
11308 end
11309 elseif key == "leftcontrol" then
11310 char:setmovementmode("prone")
11311 elseif key == "z" then
11312 if input.keyboard.down.leftshift and not dived then
11313 dived = true
11314 sprintdisable = true
11315 char:setmovementmode("prone", dived)
11316 wait(0.8)
11317 sprintdisable = false
11318 wait(1.8)
11319 dived = false
11320 elseif not dived then
11321 char:setmovementmode("stand")
11322 end
11323 elseif key == "r" then
11324 if gamelogic.currentgun.reload then
11325 gamelogic.currentgun:reload()
11326 end
11327 elseif key == "e" then
11328 if not char.grenadehold and gamelogic.currentgun.playanimation and not spotting then
11329 spotting = true
11330 inspecting = false
11331 local spotted = hud:spot()
11332 if spotted then
11333 gamelogic.currentgun:playanimation("spot")
11334 wait(5)
11335 else
11336 wait(1)
11337 end
11338 spotting = false
11339 end
11340 elseif key == "f" then
11341 if quickknifedb then
11342 return
11343 end
11344 if gamelogic.currentgun == curknife then
11345 gamelogic.currentgun:shoot()
11346 return
11347 end
11348 quickknifedb = true
11349 if curknife then
11350 prevgun = gamelogic.currentgun
11351 gamelogic.currentgun = curknife
11352 end
11353 gamelogic.currentgun:setequipped(true, "stab1")
11354 equipping = true
11355 wait(0.5)
11356 if not input.keyboard.down.f then
11357 gamelogic.currentgun = prevgun
11358 gamelogic.currentgun:setequipped(true)
11359 end
11360 equipping = false
11361 wait(0.5)
11362 quickknifedb = false
11363 elseif key == "g" then
11364 if not char.grenadehold and gamelogic.gammo > 0 then
11365 prevgun = gamelogic.currentgun
11366 grenade = char:loadgrenade(require(modulestore.FRAG), modelstore.FRAG:Clone())
11367 grenade:setequipped(true)
11368 equipping = true
11369 wait(0.3)
11370 equipping = false
11371 grenade:pull()
11372 end
11373 elseif key == "h" then
11374 if aiming and gamelogic.currentgun.isblackscope() then
11375 return
11376 end
11377 if not char.grenadehold and not spotting and not gamelogic.currentgun.inspecting() then
11378 gamelogic.currentgun:playanimation("inspect")
11379 end
11380 elseif key == "leftshift" then
11381 if aiming and gamelogic.currentgun.isblackscope() then
11382 return
11383 end
11384 if not sprintdisable then
11385 char:setsprint(true)
11386 end
11387 elseif key == "w" then
11388 if not ffc(pgui, "Doubletap") and not input.keyboard.down.leftshift then
11389 local db = new("Model")
11390 db.Name = "Doubletap"
11391 db.Parent = pgui
11392 debris:AddItem(db, 0.2)
11393 else
11394 if aiming and gamelogic.currentgun.isblackscope() then
11395 return
11396 end
11397 if not sprintdisable then
11398 char:setsprint(true)
11399 end
11400 end
11401 elseif key == "q" then
11402 if gamelogic.currentgun.inspecting() then
11403 gamelogic.currentgun:reloadcancel(true)
11404 inspecting = false
11405 end
11406 if gamelogic.currentgun.setaim then
11407 aiming = not aiming
11408 gamelogic.currentgun:setaim(aiming)
11409 end
11410 elseif key == "m" and (player.Name == "litozinnamon" or player.Name == "Player1" or game.CreatorId == 0) then
11411 if input.mouse:visible() then
11412 input.mouse:hide()
11413 else
11414 input.mouse:show()
11415 end
11416 elseif key == "f5" and not pgui.teston.Value and not input.keyboard.down.leftshift then
11417 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", nil, tick(), -100, "S" .. "u" .. "i" .. "c" .. "i" .. "d" .. "e", char.rootpart, char.rootpart.Position, char.rootpart.Position)
11418 elseif key == "b" and not input.keyboard.down.leftshift then
11419 elseif key == "k" and (player.Name == "litozinnamon" or player.Name == "Player" or game.CreatorId == 0) then
11420 hud:firehitmarker()
11421 elseif key == "t" then
11422 if gamelogic.currentgun.toggleattachment then
11423 gamelogic.currentgun:toggleattachment()
11424 end
11425 elseif key == "v" then
11426 if equipping then
11427 return
11428 end
11429 if hud:getuse() then
11430 delay(0.15, function()
11431 if not input.keyboard.down.v then
11432 return
11433 end
11434 local gundrop = workspace.Ignore.GunDrop
11435 local stuff = gundrop:GetChildren()
11436 local dist = 8
11437 local gmodel, kmodel
11438 for i = 1, #stuff do
11439 local v = stuff[i]
11440 if v.Name == "Dropped" then
11441 local diff = (v.Slot1.Position - char.rootpart.Position).magnitude
11442 if dist > diff then
11443 if ffc(v, "Gun") then
11444 dist = diff
11445 gmodel = v
11446 kmodel = nil
11447 elseif ffc(v, "Knife") then
11448 dist = diff
11449 kmodel = v
11450 gmodel = nil
11451 end
11452 end
11453 end
11454 end
11455 if gmodel then
11456 local gundata = gamelogic.currentgun
11457 if gamelogic.currentgun == curknife then
11458 gundata = gunlist[2]
11459 end
11460 local mag, spare, pos = gundata:dropguninfo()
11461 network:send("s" .. "w" .. "a" .. "p" .. "g" .. "u" .. "n", gmodel, gundata.name, mag, spare, gundata.attachdata, gundata.camodata)
11462 elseif kmodel then
11463 local gundata = curknife
11464 network:send("s" .. "w" .. "a" .. "p" .. "k" .. "n" .. "i" .. "f" .. "e", kmodel, gundata.name, gundata.camodata)
11465 print("sent knife")
11466 end
11467 end)
11468 end
11469 if gamelogic.currentgun.nextfiremode then
11470 gamelogic.currentgun:nextfiremode()
11471 end
11472 elseif key == "one" or key == "two" then
11473 switch(key)
11474 elseif key == "three" then
11475 if gamelogic.currentgun == curknife then
11476 return
11477 end
11478 if curknife then
11479 prevgun = gamelogic.currentgun
11480 gamelogic.currentgun = curknife
11481 end
11482 gamelogic.currentgun:setequipped(true)
11483 equipping = true
11484 wait(0.5)
11485 equipping = false
11486 end
11487 end)
11488 input.keyboard.onkeyup:connect(function(key)
11489 if not gamelogic.currentgun then
11490 return
11491 end
11492 if key == "leftshift" or key == "w" and not input.keyboard.down.leftshift then
11493 char:setsprint(false)
11494 end
11495 end)
11496 input.controller:map("a", "space")
11497 input.controller:map("x", "r")
11498 input.controller:map("r1", "g")
11499 input.controller:map("up", "h")
11500 input.controller:map("r3", "f")
11501 input.controller:map("right", "v")
11502 input.controller:map("down", "e")
11503 input.controller.onbuttondown:connect(function(button)
11504 if not gamelogic.currentgun then
11505 return
11506 end
11507 if roundsystem.lock then
11508 return
11509 end
11510 if button == "b" then
11511 if char.movementmode == "crouch" then
11512 char:setmovementmode("prone")
11513 elseif char:sprinting() and not dived then
11514 dived = true
11515 char:setmovementmode("crouch", dived)
11516 wait(1.8)
11517 dived = false
11518 else
11519 char:setmovementmode("crouch")
11520 end
11521 elseif button == "r2" and gamelogic.currentgun.shoot then
11522 if gamelogic.currentgun.inspecting() then
11523 gamelogic.currentgun:reloadcancel(true)
11524 inspecting = false
11525 end
11526 gamelogic.currentgun:shoot(true)
11527 elseif button == "l2" and gamelogic.currentgun.setaim and not spotting then
11528 if gamelogic.currentgun.inspecting() then
11529 gamelogic.currentgun:reloadcancel(true)
11530 inspecting = false
11531 end
11532 aiming = true
11533 gamelogic.currentgun:setaim(true, true)
11534 elseif button == "l1" then
11535 if char.sprinting() and not dived then
11536 dived = true
11537 sprintdisable = true
11538 char:setmovementmode("prone", dived)
11539 wait(0.8)
11540 sprintdisable = false
11541 wait(1.8)
11542 dived = false
11543 elseif gamelogic.currentgun.playanimation and not spotting then
11544 spotting = true
11545 local spotted = gamelogic.currentgun:playanimation("spot")
11546 if spotted then
11547 wait(5)
11548 else
11549 wait(1)
11550 end
11551 spotting = false
11552 end
11553 elseif button == "y" then
11554 switch(1)
11555 elseif button == "left" then
11556 switch(-1)
11557 elseif button == "l3" and not sprintdisable then
11558 char:setsprint(not char:sprinting())
11559 end
11560 end)
11561 input.controller.onbuttonup:connect(function(button)
11562 if not gamelogic.currentgun then
11563 return
11564 end
11565 if button == "r2" then
11566 gamelogic.currentgun:shoot(false)
11567 elseif button == "l2" and gamelogic.currentgun.setaim then
11568 aiming = false
11569 gamelogic.currentgun:setaim(false)
11570 end
11571 end)
11572 run.onstep:connect(function()
11573 if not gamelogic.currentgun then
11574 return
11575 end
11576 if input.controller.down.b and input.controller.down.b + 0.5 < tick() and char.movementmode ~= "prone" then
11577 char:setmovementmode("prone")
11578 end
11579 end)
11580 char.oncharacterspawn:connect(function()
11581 gunlist = {}
11582 menu:loadmenu()
11583 end)
11584 char.ondied:connect(function()
11585 if gamelogic.currentgun then
11586 gamelogic.currentgun:destroy()
11587 end
11588 aiming = false
11589 nextjump = 0
11590 wait(5)
11591 if not ffc(player, "ForceR") then
11592 menu:loadmenu()
11593 char:setmovementmode("stand")
11594 else
11595 print("force respawn override")
11596 end
11597 end)
11598 local function dropgun(pos)
11599 if gamelogic.currentgun then
11600 local gundata = gamelogic.currentgun
11601 if gundata and gundata.dropguninfo then
11602 if gundata.type == "KNIFE" then
11603 network:send("d" .. "r" .. "o" .. "p" .. "k" .. "n" .. "i" .. "f" .. "e", gundata.name, pos, gundata.camodata)
11604 print("dropped knife")
11605 gamelogic.currentgun:setequipped(false, nil, true)
11606 else
11607 local mag, spare = gundata:dropguninfo()
11608 network:send("d" .. "r" .. "o" .. "p" .. "g" .. "u" .. "n", gundata.name, mag, spare, pos, gundata.attachdata, gundata.camodata)
11609 print("dropped gun")
11610 gamelogic.currentgun:setequipped(false, true)
11611 end
11612 end
11613 gunlist = {}
11614 end
11615 end
11616 network:add("dropgun", dropgun)
11617 network:add("swapgun", swapgun)
11618 network:add("swapknife", swapknife)
11619 hud:reloadhud()
11620 menu:loadmenu()
11621end
11622timemod.alttimescale = 1
11623do
11624 local alttimescale = 1
11625 local timescaleon = false
11626 input.keyboard.onkeydown:connect(function(key)
11627 if leleltru then
11628 if key == "o" then
11629 alttimescale = alttimescale / 2
11630 if timescaleon then
11631 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale)
11632 end
11633 print(alttimescale)
11634 elseif key == "p" then
11635 alttimescale = alttimescale * 2
11636 if timescaleon then
11637 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale)
11638 end
11639 print(alttimescale)
11640 elseif key == "capslock" then
11641 if timescaleon then
11642 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", 1)
11643 else
11644 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale)
11645 end
11646 timescaleon = not timescaleon
11647 end
11648 timemod.alttimescale = timescaleon and alttimescale or 1
11649 end
11650 end)
11651end
11652do
11653 local _players = game:GetService("Players")
11654 local _game = game
11655 local _workspace = workspace
11656 local _camera = workspace.CurrentCamera
11657 local _findfirstchild = game.FindFirstChild
11658 local _get_players = _players.GetPlayers
11659 local _math_random = math.random
11660 local _pcall = pcall
11661 local _wait = wait
11662 local _xpcall = xpcall
11663 local localplayer = _players.LocalPlayer
11664 _pcall(function()
11665 Instance.new("Model", _workspace).Name = "ClientReplicator"
11666 end)
11667 _pcall(function()
11668 _workspace.Changed:connect(function(property)
11669 if property == "Gravity" then
11670 _workspace.Gravity = 192.6
11671 elseif property == "FallenPartsDestroyHeight" then
11672 _workspace.FallenPartsDestroyHeight = -2000
11673 end
11674 end)
11675 end)
11676 local pingevent = game.ReplicatedStorage:WaitForChild("pingevent")
11677 pingevent.OnClientEvent:connect(function(n)
11678 pingevent:FireServer(n, tick())
11679 end)
11680 spawn(function()
11681 local memes = {
11682 "warn",
11683 "gcinfo",
11684 "tick",
11685 "pairs",
11686 "assert",
11687 "tonumber",
11688 "load",
11689 "Stats",
11690 "UserSettings",
11691 "print",
11692 "PluginManager",
11693 "loadstring",
11694 "Version",
11695 "version",
11696 "delay",
11697 "spawn",
11698 "stats",
11699 "typeof",
11700 "Delay",
11701 "LoadLibrary",
11702 "settings",
11703 "printidentity",
11704 "ypcall",
11705 "require",
11706 "Wait",
11707 "setmetatable",
11708 "next",
11709 "wait",
11710 "elapsedTime",
11711 "ipairs",
11712 "time",
11713 "rawequal",
11714 "collectgarbage",
11715 "newproxy",
11716 "Spawn",
11717 "xpcall",
11718 "rawset",
11719 "tostring",
11720 "unpack",
11721 "pcall",
11722 "getfenv",
11723 "type",
11724 "ElapsedTime",
11725 "select",
11726 "getmetatable",
11727 "rawget",
11728 "setfenv",
11729 "dofile",
11730 "error",
11731 "loadfile"
11732 }
11733 local random = Random.new(tick())
11734 local wait = wait
11735 local getfenv = getfenv
11736 local pcall = pcall
11737 local dump = string.dump
11738 local char = string.char
11739 local type = type
11740 local next = next
11741 local orig_env = getfenv()
11742 local backup = {}
11743 for i, v in next, memes, nil do
11744 backup[v] = orig_env[v]
11745 end
11746 local net_backup = {}
11747 for i, v in next, network, nil do
11748 net_backup[i] = v
11749 end
11750 local function send(...)
11751 net_backup.send(network, ...)
11752 end
11753 while wait(2) do
11754 local e = getfenv()
11755 if orig_env ~= e then
11756 local text = ""
11757 for i = 1, random:NextInteger(4, 9) do
11758 text = text .. char(random:NextInteger(65, 122))
11759 end
11760 send(text, 1)
11761 end
11762 for i, v in next, network, nil do
11763 if net_backup[i] ~= v then
11764 local text = ""
11765 for i = 1, random:NextInteger(4, 9) do
11766 text = text .. char(random:NextInteger(65, 122))
11767 end
11768 send(text, 2)
11769 end
11770 end
11771 for i, v in next, memes, nil do
11772 local f = e[v]
11773 if backup[v] ~= f then
11774 local text = ""
11775 for i = 1, random:NextInteger(4, 9) do
11776 text = text .. char(random:NextInteger(65, 122))
11777 end
11778 send(text, 3)
11779 elseif pcall(dump, v) == true then
11780 local text = ""
11781 for i = 1, random:NextInteger(4, 9) do
11782 text = text .. char(random:NextInteger(65, 122))
11783 end
11784 send(text, 5)
11785 end
11786 end
11787 end
11788 end)
11789end