I’m working on a raycast gun, and I’m sending the client’s shot to the server so the server can validate it, once validated I want to fire all clients so each individual client can replicate the bullet, the only problem is my own client would end up shooting twice since my own client already creates the visuals before telling the server.
How could I exclude the client of the player who shot the bullet from fire all clients?
You can use an argument you get when receiving an event from the client.
You can then return the events with :FireAllClients() while passing the player.Name. Then you can run it through an if statement on the client, checking;
if playerNamePassedThroughEvent == player.Name then
warn("This player fired the bullet.")
else
... --//Run the code after confirming it is not the client of who fired
remote1.OnServerEvent:Connect(function(shooting_player,data_to_validate)
--Do your validation
-- Everything in order, replicate.
for _, player in game.Players:GetPlayers() do
if player == shooting_player then continue end
remote1:FireClient(data_to_validate) -- You can use the same remote on the way back.
end
end