This is a gif where the left is the other clients and the right is the LocalPlayer.
The right side is the intended effect.
As you can see, multiple particles are created in the other clients perspective, whereas in the LocalPlayer, only one particle is created for each particle emitter.
Logic goes:
1: LocalPlayer fires a bullet and creates gunshot effects using particles (bonus question, what is the performance boost of particles vs actual bullet parts for the bullet casings)
2: LocalPlayer fires to the server (without any values, all server values are fetched by the server itself)
3: Server fires to all clients (except the LocalPlayer) to replicate the bullet fired + all the gun effects with a table of effects as its arguments.
4: A localscript in the StarterPlayer will listen for the server to fire, and when it does, it will create its own client side effects to copy what the LocalPlayer sees.
The localscript that copies the effects of the LocalPlayer in other clients:
local function loadEffects(effects)
for i, v in pairs(effects) do
if v:IsA("PointLight") then
local pointLight = v:Clone()
pointLight.Parent = v.Parent
pointLight.Enabled = true
Debris:AddItem(pointLight, 0.1)
print(v, " light")
else
v:Emit()
print(v)
end
end
end
Server Fire (where “gunEffects” is a table inside a modulescript that points to the particle and pointlight objects in the gun):
for i, plr in ipairs(players:GetChildren()) do
if plr ~= clientThatFired then
SendCastEvent:FireClient(plr, "AkRound", gunEffects)
end
end
TL;DR: particles work normally in the perspective of the LocalPlayer where only 1 particle is emitted using :emit() but in other clients the particle created from emit() is 30+.
FYI: I’ve already tested how many times the function fires and if there are duplicates in the table. Also checked how many times the for loop goes through the table.