So I am making a gun using raycast, I am making a client side bullet and a server hit detection but there's one problem whenever I fire my gun, the other clients also fire their bullet without even pressing their mouse. Can anyone help me? So here's my script:
Bullet.OnServerEvent:Connect(function(player, mospos, startofbul)
local origin = startofbul.Position
local direction = ( mospos -origin).Unit
local params = RaycastParams.new()
params.FilterDescendantsInstances = {script.Parent, script.Parent.Parent}
params.FilterType = Enum.RaycastFilterType.Blacklist
params.IgnoreWater = true
local result = workspace:Raycast(origin, direction*200, params)
if result then
local hum = result.Instance.Parent:FindFirstChild("Humanoid")
if hum then
hum:TakeDamage(30)
end
end
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
bullet:FireClient(v) -- This is the problem
end
end)
I want it to be only seen by other clients, not make them fire their gun. Can anyone please give me an idea?

1 comment
The problem is most likely on the receiving end of that remote event. What you should be doing (and hopefully are) is passing the gun alongside the :FireAllClients() so the client knows which gun to show the effects for.