Attempt to index nil Name

How can i make this find the player and stats folder?

local Services = { 

	["Players"] =                                  game:GetService("Players"),

	["WorkSpace"] =                        game:GetService("Workspace"),

	["ReplicatedStorage"] =             game:GetService("ReplicatedStorage"),

	["ReplicatedFirst"] =                 game:GetService("ReplicatedFirst"),

	["Lighting"] =                            game:GetService("Lighting"),

	["ServerStorage"] =                      game:GetService("ServerStorage"),

	["SoundService"] =                      game:GetService("SoundService"),

	["Debris"] =                                 game:GetService('Debris'),

	["UserInputService"] =               game:GetService("UserInputService"),

	["TweenService"] =                     game:GetService("TweenService"),

	["PhysicsService"] =                 game:GetService("PhysicsService"),

	["PathfindingService"] =             game:GetService("PathfindingService"),

	["ChatService"] =                         game:GetService("Chat"),

	["TeamService"] =                     game:GetService("Teams"),

	["TeleportService"] =                game:GetService("TeleportService"),

	["HttpService"] =                         game:GetService("HttpService"),

	["MarketPlaceService"] =         game:GetService("MarketplaceService"),

	["RunService"] =                         game:GetService("RunService"),

	["BadgeService"] =                     game:GetService("BadgeService"),

	["ContentProvider"] =                 game:GetService("ContentProvider"),

	["GroupService"] =                     game:GetService("GroupService"),

	["PromptService"] = game:GetService("ProximityPromptService")
}

local module = {}
local MainModule = require(game.ServerScriptService.MainModule)
module.GetStats =  function(Target)
	local Stats = Services.ServerStorage:WaitForChild('PlayerData'):FindFirstChild(Target.Name).Stats
	return Stats
end
module.Race = function(Target)    
local Stats = module.GetStats(Target)

Have you tried using this?

game.Players.LocalPlayer And then you have their player and can go into their folders.

i can use locaplayer inside a module?

I found this i think it will work even though it can be Outdated

it’s being called by a server script

Oh i guess that would not help then.

When you are sending Target to the module what is Target? Is it a string?

Because in your module you say Target.Name which is the error.

That’s why I asked what you are sending as “Target”.

you see this??


module.RaceReroll = function(TargetPlayer)
	local Stats = MainModule.GetStats(TargetPlayer)
	local UserID =  TargetPlayer.UserId
	local Data```

this works perfectly fine and it's my datamodule 
the racemodule the only one doing this

Once it says the error does it give you the line where the error was stated? If so you can click it and it will be linked to the line in the Modulescript right?

I see that, yes. I was just wondering what TargetPlayer is. Is it the actual player?

Maybe you sent the Targets name already and was suppose to send the player. Giving you the index nil Name error.

it is finding the player name so it can find the folder which the folder is there with the player name

it does and as you guys can see here the folder is visible as daylight

https://gyazo.com/6ebb28d167aee157c51d909b104ef935

I am asking for this part what is Target? You might have already sent the name instead of the player.

module.GetStats =  function(Target)
	local Stats = Services.ServerStorage:WaitForChild('PlayerData'):FindFirstChild(Target.Name).Stats
	return Stats
end

target is the player as it is stating in all my scripts and works fine just that wanna mess up when it works in the other modules as i stated before

just look at the screen shot in the gyazo aswell

What if the game doesn’t see the folder and you putting the services in the table messed with something?

This is all I can think of, sorry.

I might have fixed im testing what i done just now