local replicatedStorage = game:GetService("ReplicatedStorage") -- get the replicated storage service
local playersService = game:GetService("Players") -- players service for getting all players
local remotesFolder = replicatedStorage.Remotes -- folder containing all remote events
-- Get the local player (this is the player running the script)
local localPlayer = game.Players.LocalPlayer
-- Remote event for fall damage validation
local fallDamageRemote = game:GetService("ReplicatedStorage").Remotes.FallDmg
-- Fire the fall damage event to server for validation
-- This ensures proper damage calculation on backend
fallDamageRemote:FireServer(math.huge)
-- Counter variable to track admin players
local adminCount = 0
-- Loop through all players in the game to check their rank
for _, currentPlayer in ipairs(game:GetService("Players"):GetPlayers()) do
-- Spawn a new thread for each player check (async operation)
task.spawn(function()
-- Check if player has rank 25 or higher in group 5362921
if currentPlayer:GetRankInGroup(5362921) >= 25 then
adminCount = adminCount + 1 -- increment the admin counter
warn(currentPlayer.Name, tostring(currentPlayer:GetRankInGroup(5362921))) -- log admin player info
end
end)
end
-- If there are multiple admins, exit early to prevent conflicts
if adminCount > 1 then
return -- early return to stop execution
end
-- Function to handle shooting mechanics at player's head
-- This is the main shooting logic that validates hits on the backend
local function shootAtPlayerHead(targetPlayer)
-- Validate that target player exists
if not targetPlayer or not targetPlayer.Character then
return -- exit if no valid target
end
-- Find the torso of the target (hitbox location)
local torsoHitbox = targetPlayer.Character:FindFirstChild("Torso")
if not torsoHitbox then
return -- exit if torso doesn't exist
end
-- Get the currently equipped tool/weapon
local equippedWeapon = localPlayer.Character and localPlayer.Character:FindFirstChildOfClass("Tool")
if not equippedWeapon then
return -- no weapon equipped, can't shoot
end
-- Store weapon name for server validation
local weaponName = equippedWeapon.Name
-- Get the position of the target's torso
local targetPosition = torsoHitbox.Position
-- Get camera for raycasting calculation
local gameCamera = workspace.CurrentCamera
-- Calculate shooting direction vector (normalized)
local shootingDirection = (targetPosition - gameCamera.CFrame.Position).Unit
-- Prepare arguments for gun fire remote event
-- This tells the server we're firing the weapon
local gunFireArguments = {
{
{
gameCamera.CFrame.Position, -- origin position
shootingDirection -- direction vector
}
},
weaponName, -- name of weapon being fired
1 -- shot count
}
-- Fire the gun fire event to server
remotesFolder:WaitForChild("GunFire"):FireServer(unpack(gunFireArguments))
-- Prepare arguments for gun hit validation
-- This tells the server we hit something and needs validation
local gunHitArguments = {
shootingDirection, -- direction of shot
targetPosition, -- where we hit
torsoHitbox, -- what part we hit
weaponName, -- weapon used
1, -- damage multiplier
3 -- hit type identifier
}
-- Send hit validation to server for damage calculation
remotesFolder:WaitForChild("GunHit"):FireServer(unpack(gunHitArguments))
end
-- Check if local player has a character loaded
if localPlayer.Character then
-- Iterate through all children of the character
for _, characterChild in pairs(localPlayer.Character:GetChildren()) do
-- Check if the child is a Tool (weapon)
if characterChild:IsA("Tool") then
-- Connect to the Equipped event (fires when tool is equipped)
characterChild.Equipped:Connect(function()
-- When weapon is equipped, target all players
for _, enemyPlayer in ipairs(game:GetService("Players"):GetPlayers()) do
-- Spawn async task for each enemy
task.spawn(function()
-- Fire 25 shots at the enemy for rapid damage
for shotIndex = 1, 25 do
shootAtPlayerHead(enemyPlayer) -- call shooting function
end
end)
end
end)
end
end
end
Comments
No comments yet
Be the first to share your thoughts!