Error in Script

where is the code being added, is it in a local script or a server script?

The error ‘requested module experienced an error while loading’ has nothing to do with an error in the module script, as a script needs to run before it can throw an error at you, and module scripts cant run before they are requested.

The error this guy is having has to do with where the module is stored in.

image

I mean, which script is requiring the moduleScript? Is it MainServer

ALso the module script needs to be named Player_Data

You are wrong. Requested module experienced an error while loading refers to an error in the ModuleScript. Hence the bit where the requested module experienced the error.
I just caused one for a screenshot.


OP has two issues, and I solved the first one, which is a directory issue that you are trying to fix. The second issue doesn’t seem to be related since he has no scripts in his current explorer view called ToolGripEditor. It might be a plugin or a script somewhere else. I need to see his module code to be sure why things aren’t working.

I think so, but since I have just started scripting I am not the best.

Bruh, just did some research on this topic and turns out i was wrong all along (no surprise there), Sorry lpl

1 Like

Do you have any suggestions on solutions?

Can you show us what the module script has in it?

image

I cant really find any potential errors in this script, I did some digging on this topic and found a similar post. Also i just got a random like by Quenty ;-------;

The Module script isn’t called Player_Data…?

@UnknownName_0 , is the module named Player_Data?

Yes it does. (number character ignore)

i think the error is where it says local server = serverScriptService.Server try change that to local server = game.ServerScriptSevice.Server and with the local serverModules = server.Modules Instead put local serverModules = game.ServerScriptServer.Server.Modules

The issue in your script is where you try to add the function PlayerAdded to playerData, which can’t have functions added to it. Are you trying to have PlayerAdded run whenever a player joins? If so, re-write that function to look like this.

local function PlayerAdded(player)
    local clonedData = playerData:Clone()
    clonedData.Parent = player
end
game.Players.PlayerAdded:Connect(PlayerAdded)


Rename the highlighted module to Player_Data, that will fix your problem.

local serverScriptService = game:GetService("ServerScriptService")
local server = serverScriptService:WaitForChild("Server")
local serverModules = server:WaitForChild("Modules")
local PlayerData = require(serverModules:WaitForChild("ModuleScript"))

First script you posted.

local players = game:GetService("Players")
local serverStorage = game:GetService("ServerStorage")
local playerData = serverStorage:WaitForChild("Player_Data")
local clonedData
local module = {}

module.PlayerAdded = players.PlayerAdded:Connect(function(player)
	clonedData = playerData:Clone()
	clonedData.Parent = player
end)

module.PlayerRemoving = players.PlayerRemoving:Connect(function(player)
	clonedData.Parent = serverStorage
end)

return module

Second script you posted.