Skip to content

Instantly share code, notes, and snippets.

-- Simple shooting mechanic (local script example)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
print("Player fired!")
local rayOrigin = workspace.CurrentCamera.CFrame.Position
local rayDirection = (mouse.Hit.Position - rayOrigin).Unit * 100
local Players = game:GetService("Players")
local LP = Players.LocalPlayer
local RS = game:GetService("ReplicatedStorage")
-- This function acts like a "Spy" to find the hidden hit event
local function findHitEvent()
-- Scans for any remote with "hit" or "damage" in its name
for _, v in pairs(RS:GetDescendants()) do
if v:IsA("RemoteEvent") and (v.Name:lower():find("hit") or v.Name:lower():find("damage")) then
return v