require(assetId) cannot be called from a client

so i was trying to make my sword fighting simulator and i carry on finding this

“[require(assetId) cannot be called from a client. assetId = 512742721 (rbxopenscript://www.dummy.com/dummy?scriptGuid=%7BBEF5BAB2%2D3947%2D4326%2DA6F5%2D6C13A2D0B080%7D&gst=6#35)”

also this

Requested module experienced an error while loading

and some one please tell me how i can fix this

Requested module experienced an error while loading

For this one, you either don’t return just one value from the module or there’s some other error, show us the code in the ModuleScript.

By the first error, it seems you can’t require a module through its id on the client.

It’s not clear if you’re using ModuleScripts or not, but if you aren’t, then you’re fine to ignore these. The errors are coming from plugins and internal code, not your own, since the initial testing environment is the client which those plugins can’t run on.

2 Likes

i am not using a moduel script and when i try to play my game it doesnt function bc of the 2 errors can you please tell me how to fix the script in a simple way if you need the script i will make a post tommro about it

You cannot use require() from the client, that’s intended Roblox behavior. You’ll have to use RemoteEvents to require the asset.

so i sould make a rolbox event but what sall i name it ?

-- client
local Replicated = game:GetService("ReplicatedStorage")
local Event = Replicated:WaitForChild("Event")

Event:FireServer()

-- server
local Replicated = game:GetService("ReplicatedStorage")
local Event = Replicated.Event

Event.OnServerEvent:Connect(function(Player) -- player instance is automatically sent over, but you don't need use/have it
	-- some sanity checks here in case you don't want people to abuse it.
	require(000000) -- require the module from whatever location, or by id if you have uploaded it.
end)

Hope this helps. You can probably figure out how to set things up.
Just never trust the client with any information, check everything on the server.

3 Likes

Thx for the scrip but should I put is in a new script in serverscripservice or where the old code is

Put the Script inside ServerScriptStorage. You don’t have to move the LocalScript.

Ok thank you very much for the help I will coop all the scrip and yes it Tommie on and game and come back Thank you for the help :smiley:

1 Like

i tried out the code and it doesent work this is the code i did its stll has a error

gui script:

the game script :

and stats script :

the main thing is i cant get this script to work idk why bc it works on another game

Thats because u can’t do require(assetid) from a LocaLScript

Then its probably a Plugin or internal Roblox Scripts. If the Stack Traceback points to a Plugin, make sure the plugin is using it for good use and not for malicious stuff, such as inserting a infection

I don’t know why, but whenever I open up a new studio, it has these errors as well.

I even go on another account to test it and It shows up, no idea why.

so bro what shall i do bc what else can i do instead of require a asset id also where does it say in my local scrip require(assetid)

You can use require() from the client. I’ve been using it for most of my scripts on the client if I need to use the same thing in multiple places.

In a LocalScript, you can use it for modules that are already in the game, just not assetIds.

2 Likes

so do you know in my script where is the asset id bc thats all the script and i didnt add a asset id in it ???

The StackBegin block lets us know the error is from a plugin. You do not need to worry about it.