I’m storing the data inside the module script. However, when I print the content of the module script it doesn’t show what is actually inside the module.
Server:
local PlayerService = game:GetService("Players")
local PlayerDataModule = require(game.ServerScriptService.PlayerData)
PlayerService.PlayerAdded:Connect(function(player)
PlayerDataModule.AddPlayer(player)
print(PlayerDataModule.PlayerList)
end)
Module:
local PlayerData = {}
function PlayerData.AddPlayer(player)
PlayerData.PlayerList[player.Name] = {
["Inventory"] = {}
}
end
PlayerData.PlayerList = {
}
return PlayerData
the output of the print(PlayerDataModule.PlayerList) would be just a blank table rather then the player name. Am I doing something wrong?
Well if he does that, then when he passes and argument it will throw an error saying something around the lines “Passed 1 argument but 0 parameters needed” Module’s aren’t like RemoteEvents or some events where they autopass a player.
as @NoraaApple said, if the player wasn’t sent to the function there would be no other way to create it’s own segment in the table (maybe you think the script is a local script and I’m using a remote event?)