How to insert just one Player in the table after “…MouseButton1Click:Connect(function)” in the Local-Script. I made the whole script, when i click on the Gui it send a RemoteEvent to the Server-Script and then insert Players to the table. The problem is, its insert all Players to the table but i want just one player is inserting to the table.
local exampleTable = {}
game.ReplicatedStorage.example.OnServerEvent:Connect(function(player)
table.insert(exampleTable, player)
end
if you want to put in a random player then do this
local exampleTable = {}
game.ReplicatedStorage.example.OnServerEvent:Connect(function(player)
local Players = game.Players:GetPlayers()
local RandomPlayer = Random.new():NextInteger(1, #Players)
table.insert(exampleTable, Players[RandomPlayer])
end
if you want it so you can’t have multiple of the same player tell me
Ah and i have one more quastion… How can i see if a player is in the table? When “…MouseButton1Click:Connect(function())” then i want to Remove the player in the table but i have multiple Tables.
for i, player in pairs(example1) do
table.remove(example1,player)
print("Remove1")
--else?
for i, player in pairs(example2) do
table.remove(example2,player)
print("Remove2")
end
end