0% found this document useful (0 votes)
632 views2 pages

Deadline Silent Aim Nov 2024

The document is a Lua script for a game that utilizes the ReplicatedStorage service to manage modules and implement bullet casting mechanics. It includes a function to find the closest player to the camera and modifies the firing direction of projectiles based on the closest player's position. The script also hooks into an existing function to alter projectile behavior, enhancing gameplay dynamics.

Uploaded by

xtragamer991
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
632 views2 pages

Deadline Silent Aim Nov 2024

The document is a Lua script for a game that utilizes the ReplicatedStorage service to manage modules and implement bullet casting mechanics. It includes a function to find the closest player to the camera and modifies the firing direction of projectiles based on the closest player's position. The script also hooks into an existing function to alter projectile behavior, enhancing gameplay dynamics.

Uploaded by

xtragamer991
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

local replicated_storage = game:GetService("ReplicatedStorage");

local camera = [Link];


local modules = {}; do
for _, module in replicated_storage.module:GetDescendants() do
if ([Link]([Link], "Script")) then
modules[[Link]] = module;
end
end
end

local caster = require([Link]); -- important (bullet casting)


local stats = require(modules.shared_state).SHARED_STATE; -- some cool stuff in
here, [Link] to check it out
local ray_casts = require(modules.parallel_raycast); -- not as important, their
raycasts

local get_closest_player = function()


local closest_distance = 300;
local closest_player = nil;

for _, player in [Link]:GetChildren() do


if (player:FindFirstChild("hitbox") == nil) then
continue;
end

local center = [Link]([Link].X / 2, [Link].Y


/ 2);
local position, on_screen =
camera:WorldToViewportPoint([Link]);

if (on_screen == false) then


continue;
end

local distance = (center - [Link](position.X, position.Y)).Magnitude;

if (distance > closest_distance) then


continue;
end

closest_distance = distance;
closest_player = player;
end
return closest_player;
end

--local projectiles = getupvalue(caster.fire_server, 5); -- (all alive projectiles


r stored here, might do something with this in the future)
old_fire_server = hookfunction([Link], function(_, origin_pos, direction,
data, ...)
local closest_player = get_closest_player();

if (closest_player) then
origin_pos += [Link](0, 30, 0); -- bullets fire from higher up, pretty
op..
direction = (closest_player.[Link] - origin_pos).Unit * 1000;
end

return old_fire_server(_, origin_pos, direction, data, ...);


end)

You might also like