How do I receive the table from a RemoteEvent

When ever I fire the remote event with the FireClient(plr, atable) on the second argument its sending me a nil here’s the script for the server:

gameTable.imposterTeammate = function()
	local event = game:GetService("ReplicatedStorage").Events.RemoteEvent
	
	for i, players in pairs(gameTable.imposters) do
		event:FireClient(players, tostring(gameTable.imposters.Name))  --Even if I remove the tostring still a null
	end
end

Here is for the localscript:

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

event.OnClientEvent:Connect(function(msg)
	print("fired")
	print(msg)
end)

Any idea on how I can receive the table using FireClient() .

Its simple your trying to index the name of a table which is impossible try changing the gameTable.imposters.Name to players.Name and that should work

2 Likes

How do I get the second Player’s name Its only sending me one?

Or should I use if not players.Name then.

what do you mean its only sending you one name?? are you sure the table has two names inside?

I am try to get all the names inside the table to make a billboard that only those players can see.

oh i see what your trying to do.

gameTable.imposterTeammate = function()
local event = game:GetService(“ReplicatedStorage”).Events.RemoteEvent
for i, players in pairs(gameTable.imposters) do
event:FireClient(players, tostring(gameTable.imposters.Name)) --Even if I remove the tostring still a null
end
end

your code is possibly incorrect.

it should be something like this

gameTable.imposterTeammate = function()
local event = game:service(“ReplicatedStorage”).Events.RemoteEvent
event:FireAllClients(gameTable.imposters)
end

tell me if it works : D

1 Like

I can’t use event:FireAllClients() because all the players will receive it.

you can then add some code on the client side to check if their name is inside of that table something like

if not table.find(msg,game.Players.LocalPlayer.Name) then return print("This Message is not for me.") else print("This message is for me") end
1 Like

Are you trying to return the table to the client? If so, have you tried a RemoteFunction?

1 Like

That’s what I realized thank you so much it help me a lot, but can exploiters use this advantage like they will make a table and put their names and use event:FireAllClients(“there names.”).

no because :FireAllClients Can ONLY be used on the server side

2 Likes

I thought of using remote function actually but I don’t know its invoke for client.

A client can only use Event:FireServer() and Event.OnClientEvent . The client cannot call :FireClient() or :FireAllClients() on any event, nor can it read Event.OnServerEvent . All a client can do is listen for events from the server or send an event to the server. The client cannot send data between clients without going through the server first. Therefore, the server should act as a filter between clients, and it’s your job as a scripter to create that filter and only let through what your game decides is allowed to be let through.

1 Like

Here are links to the Roblox Developer Hub and what it has to say about Remote Event & Remote Functions.

Remote Functions
Remote Functions & Events

These should give the needed information.

I’m still unclear about what you want to accomplish.

Hes trying to send a table of players who can see a certain billboard gui and so hes using remote events to notify the clients who are involved.

Is there any chance that we could see what exactly is stored into gameTable.imposters?

this topic has already been solved as you may see in post 6.

This will run twice because if there are more 10 players in the game then it will run twice.
Because I want to let those two imposter know where its teammate are all the time that’s why I am trying to send the table for the imposters to the players who has it and create a billboard gui.

gameTable.chooseTheImposter = function()
	local getPlayers = game:GetService("Players"):GetChildren()
	local chosen = math.random(1, #getPlayers)
	local chosenPlayer = getPlayers[chosen]

	if gameTable.inGame[chosen] then
		if not gameTable.imposters[chosen] then
			gameTable.removePlayer(chosenPlayer)
			return chosenPlayer
		else
			wait()
			return gameTable.chooseTheImposter()
		end
	else
		wait()
		return gameTable.chooseTheImposter()
	end
end

Thanks. So it’s just choosing a player at random? has your problem been resolved? I hadn’t noticed if it has been.

Well the thing is I tried

gameTable.imposterTeammate = function()
local event = game:service(“ReplicatedStorage”).Events.RemoteEvent
event:FireAllClients(gameTable.imposters)
end

That Harry_TheKing1 typed, its still giving me the same name.
Screenshot_1

gameTable.imposterTeammate = function()
	local event = game:GetService("ReplicatedStorage").Events.RemoteEvent
	
	for i, players in pairs(gameTable.imposters) do
		event:FireAllClients(players.Name)
	end
end