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