0

# Table keeps returning "nil" for some reason?

so i am trying to use a table to store loadout data in my game, but every time i try to use the table it tells me it's just nil. i have 2 potential culprits in my loadout handling server-side script:

local dataStore = game:GetService("DataStoreService")
local replicatedStorage = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(player) -- gets the player's loadout presets when they connect, gives them empty presets if there's no data
local userId = player.UserId
if serverLoadouts[userId] == nil then -- checks if the player has loadout information
--"empty" loadouts (just the loadout structuring but all the items are "empty", also has nested dictionaries)
}
} -- ends the default loadout
end -- ends the if statement
end) -- ends the function PlayerAdded


which is supposed to take the loadout data from a datastore, and give a default loadout if they've never connected before

and

replicatedStorage.returnServerLoadouts.OnServerInvoke = function(clientId)