Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cant use loadstring() function on require script i made?

Asked by 4 years ago
Edited 4 years ago

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
0
How are you using loadstring? ew_001 58 — 4y
0
loadstring("require(6153080832):A('rookiecookie153')")() rookiecookie153 53 — 4y

2 answers

Log in to vote
1
Answered by
ew_001 58
4 years ago
Edited 4 years ago

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.

0
OML IM SO SORRY IT WAS A ROBLOX ERROR. Error: Downloading Asset failed for (ID) rookiecookie153 53 — 4y
0
Want nvm sorry rookiecookie153 53 — 4y
Ad
Log in to vote
1
Answered by
imKirda 4491 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

You cant call loadstring on a function, string only. Or what are you trying to achieve?

0
Sorry, i know that, but for example, i mean games like script fighting. Their require executor uses loadstring() to run code that is put in. I tried to put this require script inside of it, but it did nothing. not even an error when i used pcall. rookiecookie153 53 — 4y

Answer this question