Why does it say ServerScriptService.Player data:90: attempt to index nil with 'FrenchFry3'

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? why isnt it working

  2. What is the issue? I cant figure it out, its been about 4 hours and im about to lose my mind, it keeps saying: ServerScriptService.Player data:90: attempt to index nil with ‘FrenchFry3’

I have tried everything, even rewriting the script. MAYBE it could have something to do with my Module script?

Here is my Script:

local success, returnValue
success, returnValue = pcall(dataStore.GetAsync, dataStore, key)
until success or not Players:FindFirstChild(player.Name)

if success then 
	if returnValue == nil then 
		returnValue = {
			Food = 0, 
			Coins = 0,

	player.leaderstats.Food.Value = if returnValue.Food ~= nil then returnValue.Food else 0
	player.leaderstats.Coins.Value= if returnValue.Coins ~= nil then returnValue.Coins else 0
	player.inventory.EquippedTool.Value = if returnValue.Inventory.EquippeedTool ~= nil then returnValue.Inventory.EquippeedTool else "FrenchFry"
	for _, tool in ipairs(player.inventory.OwnedTools:GetChildren()) do
		tool.Value = (returnValue.Inventory.OwnedTools[tool.Name] or false)
	player:Kick("There was an error loading your Data! Roblox's DataStore might be down, try again later!")
	print(player.Name.."Data loading ERROR!!!")

Here is my Module script:

local module = {
FrenchFry = {Name = “French Fry”, Food = 1, price = 0},
FrenchFry2 = {Name = “French Fry2”, Food = 2, price = 10},
FrenchFry3 = {Name = “French Fry3”, Food = 3, price = 25},


return module

It would help greatly to know which line in specific the error is happening on: what is line 90?


Thats why I said it could be my module, with it saying nil.

hmmm where is the module script being required

Im still new to scripting so i have no clue but i read something about index nil where it says index nil means that the script cannot find the object. This often is because the path to the object is wrong.

1 Like

yes that’s why I wanted to see how the module script was required

You are not providing enough information, please provide this module fully. As well as where you require this module.

We would need to know what returnValue.

Also please can you describe what you are doing instead of just giving us a script and trying to get us to understand, “why isnt it working” is not a good achievement.

based on what i can see i can only say that FrenchFry3 is not in returnValue.Inventory.OwnedTools[tool.Name] or the path doesn’t exist to begin with

1 Like

Don’t make multiple posts for the same thing, why did you mark the previous one solved if it wasn’t?


Based on the provided snippet, returnValue is missing necessary keys.

In one scenario, if returnValue is not fetched from the DataStore, then it defaults to a dictionary that is missing an Inventory array, which will cause an error when attempting to access returnValue.Inventory.OwnedTools. This doesn’t seem to be the error occurring here though.

Presumably, returnValue.Inventory exists, but returnValue.Inventory.OwnedTools does not. I can’t say for certain where you should be adding the OwnedTools table, but it does need to be added somewhere. If you don’t want to do this, then you can rewrite line 90 to handle a nil table value:

tool.Value = if (returnValue.Inventory and returnValue.Invevntory.OwnedTools and returnValue.Inventory.OwnedTools[tool.Name]) then returnValue.Inventory.OwnedTools[tool.Name] else false

Slightly messy ternary operator, but it gets the job done.


I made this in the heat of the moment but may you tell me what information you need? But I’m trying to go through all the owned tools that I added to the players inv such as French fry, French fry2,French fry3. and its not giving the tools to them. before I added the “tool.Value = (returnValue.Inventory.OwnedTools[tool.Name] or false)” line of code it was working but now its not.

1 Like

I told you exactly what we need, could you read a bit more carefully please, we need the full script which contains line 90 as well. That way we can easily help you and find out the issue without having to ask you for more.

1 Like