I’m creating a party system. This is handled entirely in a module script, with server scripts being able to set and grab information. All of the party information is stored inside of a dictionary. For simplicity, each party is indexed by the party’s host.
For visualization, this is how the data is stored:
PlayerParties = {
[PlayerInstance] = {
["Players"] = {
PlayerInstance,
PlayerInstance2
},
-- other items stored
},
-- more indexes
}
I haven’t had any problems accessing the Host player instance from the index until I tried to create the ui based party joining system, in which host returns as <Instance> PlayerName
.
I send the party information to the client by sending a RemoteFunction to the server that will return the party dictionary from the module.
For some reason in the client, I can’t (or just don’t know how) to get the player instance from the dictionary index.
This is the code on the server that sends the client the dictionary.
Remotes.GetEntirePartyList.OnServerInvoke = function(player)
local list = PartyHandler.getEntirePartyList()
for host, info in pairs(list) do
print("Host:", host)
end
return list
end
Output >>
Host: MayorGnarwhal -- player instance
However, when I receive the dictionary on the client, I’m not getting the player as I loop through the indexes
local function displayPartyInformation()
local partyDictonary = Remotes.GetEntirePartyList:InvokeServer()
print(partyDictonary)
for host, info in pairs(partyDictonary) do
print("Host:" .. host)
-- do stuff with that info
end
end
Output >>>
table: 0x85741e02ca0f9e13 -- dictonary does exist
Host: <Instance> (MayorGnarwhal) -- isn't player instance (typeof(host) reveals its a string
To display the information I want, I need the player instance to get the name and userId, but this is something I haven’t seen before, so how can I get the player instance?