:FireClient() not replicating

The issue I am having is that this code,

for i,v in pairs(game.Players:GetPlayers()) do
  if (v.Character.HumanoidRootPart.Position-Plr.Character.HumanoidRootPart.Position).Magnitude <= 250 then
		VisualEvent:FireClient(v,Plr,"HitHumanoid",object,position,normal)
	end
end

does not replicate for other players except for the player that makes it fire. The player uses a tool, fires a remote to the server, and then the server fires the remote back to all clients.

1 Like

:FireAllClients() doesnt work either

The first parameter is always the player when calling FireClient. Also, just to be sure, you’re not calling this on the client right?

1 Like

Yep, v is the player. Nope I am calling it on the server.

Okay so this must be an issue with the code that is receiving/sending the event?

1 Like

I suppose so. I’ll run a 2 player test server, have it print and see if it shows up on the other player.

Nope, it hasn’t printed anything
plr1
imageZ
player 2
image

I’d check the code that’s going client → server for any issues

1 Like

the condition in your if statement could be not true, try adding a print inside the statement to check if the condition is true

It printed but it did print at any distance. It also still didnt print in the other player. Both local and server scripts are inside a tool if that has to do with anything. The OnClientEvent is on the same local script that fires to the server script.

Could it be because there are multiple remote events, and they are connected to different onclient events?

:GetPlayers() will not work the way you want it to

that returns an array (or table i forgot) of players, those players do NOT have character in them
(it’s just the Players directory inside explorer)

if you want to get the player, you need to do :GetPlayerFromCharacter

additionally, what is the Plr variable for?
with this code you have 2 player variables, where 1 returns an array of players

It seems like you need to exclude the Plr player from GetPlayers(). Add something like
if v.Name~=Plr.Name then
Also, does :FireAllClients() return any errors?

This loop goes through every player in the array. v is each player, not GetPlayers() itself. Player.Character will give the character of the player – he isn’t trying to get any players from characters.

ohhh i thought he was trying to do something else

mb lol

but then isn’t it just better to use the already existing Plr variable?? this for loop looks kinda pointless to me

Do you understand the code at all?

yeah i do charrrr limithgffhfhfghgf

FireClient only accept two parameters. The player to send, and any data. Put all the data into a table.

1 Like

That’s not true. The player must be the first parameter, but after that there can be any amount. No table needed.

Am I tweaking? I only remember using plr parameter than a table.