@MakerDoe There should be two separately firing of the client, one for each of the players. Perhaps it is showing up as nil because you have attempted to consider both at the same time?
You should have both separately fired, as the for-loop is doing. then print the name one at a time.
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.
@Extuls is completely right. If you were to fire all of the clients, and check which players are the imposters on the client instead of the server, exploiters could detect which players are the imposters.
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
actually I already tried this but it keeps giving me a nil when getting the second player’s name
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:
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)