How do I receive the table from a RemoteEvent

In addition to this i use scripts who can access server storage and using bindable events i am sure that exploiters can not read anything and then to send stuff to that specific player i use a remote event because last time i checked exploiters can not access other’s player gui’s

1 Like

i am gonna write some code in prevention for that then.

actually I already tried this but it keeps giving me a nil when getting the second player’s name
Screenshot_1

Could you send me the client event, the script that’s printing the names?

I believe your original code would work, but are you not considering each player separately in the local script? This should not print both at the same time. But rather, it should be printing something similar to:

07:55:58 -- fired
07:55:58 -- Player1
07:55:58 -- fired
07:55:58 -- Player2

sadly roblox is down right now so i can’t tell if the script i made is working or not:

I just changed it but I just use print(msg)

1 Like

Okay so if this doesn’t work then im confused.

i have tested this so its should work.

Baseplate.rbxl (23.0 KB)

Any way I found a solution that is working now, but the only thing is that its printing it twice or firing it twice server script:

gameTable.imposterTeammate = function()
	local event = game:GetService("ReplicatedStorage").Events.RemoteEvent
	local imp1 = gameTable.imposters[1].Name
	local imp2 = gameTable.imposters[2].Name

	event:FireAllClients(imp1, imp2)
end

localscript:

local event = game:GetService("ReplicatedStorage").Events.RemoteEvent
local plr = game.Players.LocalPlayer.Name

event.OnClientEvent:Connect(function(imposter1, imposter2)
	if imposter1 == plr then
		print(imposter2)
	elseif imposter2 == plr then
		print(imposter1)
	end
end)

The reason for this is because you are firing the clients for each imposter. 2 imposters in the for-loop will make it fire all clients 2 times.

1 Like

I see so how do I make so that It will only fire once?

also as @Extuls said you are firing to all clients

What do you mean by that can you explain it to me?

exploiters can then read that by using a simple script:

local event = game:GetService("ReplicatedStorage").Events.RemoteEvent event.OnClientEvent:Connect(function(imposter1, imposter2) print(imposter1,imposter2) end)

in my test game i made sure that only the players who were the imposter were notified.

So how do I avoid it so they can’t get who are the imposters?

image

image

image

image

this is how i setup my game.

it also works if you use the game file i provided in How do I receive the table from a RemoteEvent - #51 by Harry_TheKing1

1 Like

Wait I don’t get it

I highly recommend against using FireAllClients. If an error is thrown, your code won’t be ready to try again for that specific player, and in this specific case there’s another issue that will come up. Use FireClient, and wrap it in a pcall.
In your case here, you definitely don’t want to FireClient for anyone besides the imposters. Exploiters can and will write a script to detect who the imposters are. At no point in time can you let them have access to this info so easily.

explanation: i pass it to another server script which gets copied to every single players player gui and seeing that they can not access server storage they can not see the remote then the script in every player’s player gui checks if the player is in the imposters table and then if they are send a signal to a remote event in the player gui (exploiters can not see other players player gui) so then thats also safe then the local script waits for a signal and then you can do your stuff on the client.

1 Like

I truly believe that your original script will work. You just need to change it back to the modified version of your original script, which I sent you:

gameTable.imposterTeammate = function()
	local event = game:GetService("ReplicatedStorage").Events.RemoteEvent
	
	for i, players in pairs(gameTable.imposters) do
		event:FireClient(players, players.Name) -- Modified to use 'players.Name' instead of 'gameTable.imposters.Name' because you have already been looking for the imposters in your for-loop
	end
end

You just need to consider each imposter/player separately.

Your for-loop goes through each imposter. So it will run whatever code is in the loop, as many times as the amount of imposters you have. In this case, you have 2 imposters. So the for-loop’s code will run 2 times. This is the reason that you do not need to use :FireAllClients(), but instead fire each client separately, because you are already going through each and every imposter. That way, the client event will fire 2 times, once for each imposter.

All you need to do is print the name of each imposter separately, for example:

local event = game:GetService("ReplicatedStorage").Events.RemoteEvent

event.OnClientEvent:Connect(function(msg)
	print("fired")
	print(msg) -- This will print each player's name separately
end)

Make sure you aren’t trying to print both at the same time.

Let me know if that makes sense, and if so, please try that and show me if it works.

When you get the chance to try it again. I am certain this will work.

I thought that using FireClient() is not the option since exploiters can see who was targeted.

If I use the FireAllClients() can exploiters access its arguments?