Background:
Using OOP, I create a dictionary whenever someone creates a server in my game, passing through the following variables:
which is fine and dandy, however, I wish to pass this onto the client whenever a new player joins the game, to show all the available servers, and I do this as follows:
First I use OOP to create a dictionary called “Server” and I name it after the user’s ID :
Example: Server[1234567] is basically Data[1234567] in a more common sense except each client gets a different dictionary. Simple enough. This all works.
The part that breaks is when I new player joins I have this function:
game.Players.PlayerAdded:Connect(function(plr)
for i,v in pairs(Server) do
local Table = HTTP:JSONEncode(Server[i])
RE:FireClient(plr,nil,"PlayerJoined",nil,nil,Table)
print(i)
end
end)
In which fires over a JSON encrypted table, cool, it prints the users id afterward. When I Collect it on the server, I Decode it -
local Dictionary = HTTP:JSONDecode(JSON)
local Player = Dictionary["Player"]
local Password = Dictionary.Password
print(Player)
(JSON being the sent over table)
Player in this case prints nil. This is the error and I have no idea why it does this.
TD;LR: Used OOP, Set a dictionary to the players User Id, Encrypted it with JSONEncode, sent to the client, error occurs.
If anyone can help me out that would be great thanks!