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