I believe UserData is what you’re looking for, it is:
A table where the user can store arbitrary information pertaining to this ActiveCast
so you can store the player when you fire:
SomeEvent.OnServerEvent:Connect(function(player)
local cast = caster:Fire(origin, direction, velocity, behavior)
cast.UserData.Player = player
end)
and then access it in the RayHit event:
local function onRayHit(cast, rayResult, velocity, bullet)
local playerWhoFired = cast.UserData.Player
end