Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does the Code fail to get the Module, then return an Error?

I have starting using ModuleScripts, but, whenever I use one, it errors if I attempt to get the Model by it's ID.

The error is Unable to find module for asset id, when I had published the Module on the official Website, and got the correct ID.

I fail to understand why I keep getting this error, as it does not make sense to me.

This is the code I have created (one of some of the codes I've made) to get the Module;

if msg:lower():sub(1,3+#Prefix) == Prefix.."ss " then
	local plrz = GetPlr(plr,msg:sub(4+#Prefix))
	for i,v in pairs(plrz) do
		spawn(function()
			if v and v.Character and v.Character:FindFirstChild("Humanoid") and v:FindFirstChild("Backpack") then
				if not require(247523883) then return print("Error occurred!") end
				local ROrb = require(247523883):Clone();
				ROrb.Parent = v.Backpack
				v.Character.Humanoid:EquipTool(ROrb)
			end
		end)
	end
end

11 comments

0

Your problem is that you're attempting to perform require on an ID, when it has to be done on a modulescript.

0

The Model I published is a ModuleScript though, also, it does not have to directly be in the game to call the Module, as the person in charge of fixing all of ROBLOX's gears did this.

0

Are you sure the asset ID is correct? The script is was published by itself, not in a model or anything?

0

Was it supposed to be in a 'Model' Instance? o_e Also, I thought the ID is correct, because I don't understand it having to create a Second Model of the same thing (Like Decals; There are two copies of the same thing, but perform two separate tasks).

0

are you just uploading the module script to ROBLOX? and not like a model with the script in it

0

I uploaded the Model with the ModuleScript with it; The Model is inside the ModuleScript, and the ModuleScript is supposed to return it.

0

Ro-ORB model?

0

Yes, that is the name of the Published 'Ro-Orb Model'.

0

Can't figure it out. other modules work just fine. I Believe the problem may be because it contains a model itself.

0

Interesting, I didn't know you could use an Asset Id

1 answer

✓ Accepted answer

Make sure that the name of the published module in named MainModule, otherwise it won't work as expected.

Note: what I mean by 'name' is the name of the actual instance you uploaded.


Then you can use it with the require function. With arguments of either an asset URL or just the asset ID.


Also, be wary that on line 7 then you're using the clone method directly off of the require method. This will only work if the module you're using the function on returns an instance!

3 comments

0

Thanks man, this fixed the code! :D But, why is it required to name the Module 'MainModule' for it to work?

0

Idk, roblox is silly(:

0

Yep. Haha! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.