how would i send the playerlist table to another script, I was making a party system so the player list is going to be different for each party.
local button = script.Parent
local player = game:GetService("Players").LocalPlayer
local mainmenu = player.PlayerGui.MainMenu
local plrstats = mainmenu.Stats
local playerlist = {}
button.MouseButton1Click:Connect(function()
if button.Parent.PartyAmmountCloned.Value ~= button.Parent.PartySizeCloned.Value then
table.insert(playerlist, player)
print(playerlist)
else
print("full")
end
end)
You’re going down the wrong design path for a system like that. If you want to join a party by pressing a button, you’ll need to use a RemoteEvent to ask the server to join that party—the server will be the one managing all parties. Another RemoteEvent and RemoteFunction will be used to request initial available parties and their details, as well as update party details
The simplest way you can share a table with another script running in the same context (e.g. server vs client) using BindableEvents. Generally a better way to share a table is to have both the scripts require a ModuleScript, then have the table returned by the ModuleScript store the table you want to share.
But as Ziffixture said, you probably want your button to send a remote event to the server at some point so your parties are synced.
If you want to replicate a table you can use a RemoteEvent or something like Replica (maybe more complicated than you need for just a player table, Replica is more for larger data structures that have small changes that need to replicate).