Require don't work

hi, im pretty new at things that use require() and i use require(4585283656) but it always error:

[11:44:26.457 - Unable to find module for asset id]

i tried to make it copyable but still don’t work, what is wrong? my module:

https://www.roblox.com/library/4585283656/DataStore3

1 Like

Hey, I went ahead and checked your module.

The problem is that your module is named DataStore3
To fix the issue I recommend renaming it to MainModule
And then save your changed!

Hope this helped!

still don’t work, i need to change asset name or the module name?

that’s probably not the solution, @briana_superstar please share your current code so we may assist you.

ok, the code:



local DataStore3 = require(4585283656)
local settings = DataStore3.settings

settings.StoreSaving = true
settings.AutoSaveable = true
settings.MainParent = 'leaderstats'
settings.TableSaving = false

DataStore3:CreateValue('XP','XPSavingKey',0)

game.Players.PlayerAdded:Connect(function(plr)
	
	
	local leaderstats = DataStore3:CreateLeaderstats()
	
	DataStore3:SetParent('XP',leaderstats)
	
   local XP = DataStore3:GetObject('XP',leaderstats)
	
	XP.Value = DataStore3:GetValue('XP',plr,0)
	
end)


Sorry for the confusion!
I meant change the modules name as seen below:
image

that doesn’t affect anything, you can name the required module whatever you want, as long as it’s owned and inserted in your game manually,
@briana_superstar make sure you own the asset or you won’t be able to require it.

If that doesn’t help than just keep the module manually parented to server script service and require it from there

yeah, it is my own asset, and @Enomphia i made what u say, it works and now error: [12:01:04.264 - 12:01:04.264 - ServerScriptService.leaderstats:4: attempt to index local ‘settings’ (a nil value)

Naming matters if the module is being required by its asset id. The module must be named MainModule otherwise the require will throw. Modules can be named what you want if they’re present in the DataModel at the beginning.

See the last paragraph of the ModuleScripts explanation on its API page:

1 Like