How can I make FastCast fire on all clients instead of the server?

I’ve been having trouble with lag issues due to FastCast being used so much on the server. I’ve been trying to convert it to making client do the casting, and making the server detecting the hitting. Hasn’t been going well.

Client Script (StarterPlayerScripts)

local replicated = game.ReplicatedStorage.Events
local Remote = replicated.Remotes.FastCast.ClientBulletCast

local cast
local function onLengthChanged(cast, lastPoint, direction, length, velocity, bullet)
	if bullet then
		local bulletlength = bullet.Size.Z/2
		local offset =,0,-(length - bulletlength))
		bullet.CFrame = CFrame.lookAt(lastPoint, lastPoint + direction):ToWorldSpace(offset)
	game.Debris:AddItem(bullet, 2)


Remote.OnClientEvent:Connect(function(hitPos, CoreAttachment, MIN_SPREAD, MAX_SPREAD, castBehavior,  caster, castParams)
	cast = caster
	local RayCastParams =
	RayCastParams.FilterDescendantsInstances = {}
	RayCastParams.FilterType = Enum.RaycastFilterType.Blacklist

	local origin = CoreAttachment.Effects.WorldPosition
	local directionf = (hitPos - origin).Unit
	local directionCF =, directionf)
	local spreadDirection = CFrame.fromOrientation(0,0,math.random(0, math.pi *2))
	local spreadAngle = CFrame.fromOrientation(math.rad(math.random(MIN_SPREAD, MAX_SPREAD)),math.rad(math.random(MIN_SPREAD, MAX_SPREAD)),0)
	local direction = (directionCF * spreadDirection * spreadAngle).LookVector

	caster:Fire(origin, direction, 1250, castBehavior)

Server Script, the fire function. (inside the gun)

local caster =
local castParams =
castParams.IgnoreWater = false
local castBehavior = FastCast.newBehavior()
castBehavior.RaycastParams = castParams
castBehavior.Acceleration =, 0, 0)
castBehavior.AutoIgnoreContainer = false
castBehavior.CosmeticBulletContainer = BulletsFolder
castBehavior.CosmeticBulletTemplate = Bullet
castBehavior.MaxDistance = MaxRange
local Fplayer

FireEvent.OnServerEvent:Connect(function(player, hitPos)	
	Fplayer = player
	castParams.FilterDescendantsInstances = {player.Character, BulletsFolder}
	Magazine.Value = Magazine.Value - 1
	for i, v in pairs(VisualAttachment:GetChildren()) do
		if v:IsA("ParticleEmitter") then
	game.ReplicatedStorage.Events.Remotes.FastCast.ClientBulletCast:FireAllClients(hitPos, CoreAttachment, MIN_SPREAD, MAX_SPREAD, castBehavior, caster, castParams)
		VisualAttachment.LIGHT.Enabled = false

I keep getting this error on the FireAllClients line.

Any help to convert fastcast to client is appreciated.

Client tells server they fired a bullet and where

Server sends that info to every other client

Client creates a new cast object and takes in the positions sent to the server. You’re basically just transferring the data you sent in Caster:Fire() to every client.

That’s sorta how I do it

The error you’re getting is basically:

ModuleA requires moduleB
ModuleB requires moduleA

You can’t do that as it’ll repeat the returned information recursively. Instead you could put it in a new scope (do end) or just fix your design. When I used fastcast I’ve only ever that error when I’m sending over data I’ve sent from server to client to server. Making a new copy normally fixes it for me

Hi hello! I hope you’re still active on your game, You might need to replace the event to a Module, It works for me!