I'm attempting to use a require script I made, but loadstring() does not seem to be doing the trick. If I don't use loadstring, it works somehow. Any help?
Require Method: require(6153080832):A("rookiecookie153")
Actual Script:
local module = {} function module:A(player) local sc = script:WaitForChild("char") sc.Parent = game.ReplicatedStorage local a local ret local scrip = script.Animate a = pcall(function() ret = game.Players[player] end) if a == true then sc.Name = ret.Name script.Parent = workspace local char = ret.Character local pos = char:GetPrimaryPartCFrame() char:Destroy() ret.Character = sc sc.Parent = workspace sc:SetPrimaryPartCFrame(pos) scrip.Parent = sc scrip.Disabled = false end script.Parent = game.ReplicatedStorage end return module
1.
Now, this looks like a Script Builder script. And i do make scripts myself for those games.
But, if you are trying to use loadstring to load a source, like the source you provided. Then how are you doing it currently?
Loadstring takes in 1 arguments, a string, which is the source you want to run in a string. Loadstring returns a function that can be called to run the source.
An example of loadstring could be someting like this.
loadstring("print('wow')")() -- Prints "wow" in output
Also remember that loadstring requires game.ServerScriptService.LoadstringEnabled to be true, and it can not be used inside local scripts.
But if you do want to run it in local scripts to, you can use this module.
And heres how to use that module.
local LoadstringModule = require(Path) -- Replace "Path" with the path to the loadstring module LoadstringModule("print('This works on client and server!')")() -- Prints "This works on client and server!" in output
I hope this helps!
2.
Does it work in command bar? If not, then the problem is with the require.
For a require to be able to be required with numbers, there is 2 things to keep in mind.
First, the module that you uploaded needs to have the name "MainModule".
Second, if you are requiring it from a place that you do not own, when uploading it. You need to make sure allow copying is on. This allows other places to get the require.
You cant call loadstring
on a function
, string
only. Or what are you trying to achieve?