I want to make a random killer, but when I want to send the results of the random to the client in order to then show the players on the screen their roles, I get this error
local function pick()
local plrsg = plrs:GetChildren();
local monsterchoose = math.random(1,#plrsg);
for i, ms in pairs(plrsg) do
if i == monsterchoose then
monster = ms;
print(monster);
break;
end
end
for i, ms in pairs(plrsg) do
if i == monsterchoose then
else
table.insert(survivors,ms.Name);
end
end
print(monster);
roleremote:FireClient(plrs[monster]);
end
FireClient requires a Player in order to function, if you have aguments that you want to put in place, you first specifiy the Player you want it to fire towards, and then your arguments.
OnClientEvent does not have a Player argument declared like OnServerEvent.
If you intend to have this affect all Players on their Clients Respectfully, you use FireAllClients, it does not require a Player to fire as it will fire to all Players.
plrs[monster.Name]) is the first argument needed just to determine which client it will send the event to.
add a second argument which is what you want to pass to the client
ex:
roleremote:FireClient(plrs[monster.Name,monster]) -- as you're trying to pass the player{monster) to the client you're sending too
``
roleremote.OnClientEvent:Connect(function(plr) -- the "plr" would be defined as the second argument in the other script passing to this client as the first one here.
print(plr);
end)
the first argument in the other script just defines what client to send to