How do I receive the table from a RemoteEvent

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?

No, we were saying the opposite. FireAllClients() should be avoided in this case because then you have to check from the client who is the imposter. So then the exploiter will be able to see whose names are the imposters. Remember that exploiters can manipulate things on their client. So you don’t want to give them the chance of seeing who is the imposter.

If you use FireClient(), only for those specific players will the event fire. So the exploiter won’t be able to see who is the imposter, because they can only see from their client.

1 Like

Then I should be using FireClient() instead of FireAllClients().

So FireClient() possible for me to use for giving money to the players?

Yes, definitely. Then only the imposters will know who they are, and will not give an exploiter the chance to see who they are.

You really should only handle player money from the server. But you could use fireClient() to display a gui to the player informing them of the money they received.

1 Like

Oh I see, so the solution to all of this madness is this:

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

	for i, players in pairs(gameTable.imposters) do
		event:FireClient(players, imp1, imp2)
	end
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)

I can see that you don’t have a fully developed understanding of the differences and relationship of servers to clients. I can give you the links to various information on this matter which will help you to understand clients and servers. That way, you should be able to work things out properly.

How to Prevent Exploiting - TheDevKing

Roblox-Client-Server-Model

1 Like

Please consider this solution.

1 Like

I can understand it a little but when ever a new information comes up to me my Brian get’s confused.

Yeah, no problem. It’s all about learning my friend :slight_smile:. You just need to keep learning and you’ll understand how to make things work really soon.

The video by TheDevKing really helped me understand how all of this works. Please consider watching the video and reading the topic I sent you. Hope the scripts that I sent work for you, and that you understand things well from these. And to be honest, I didn’t really do anything, you already had a working script, all I did was modify it. So you are doing really well already.

Let me know if it does or doesn’t work. I want to see this through that it gets working the way you want it to.

1 Like