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

[Loadstring] Why did I get this, and how can I use it?

Hey all.

I just discovered loadstrings and experimented a little. I was puzzled when I saw these results.

location = loadstring(script.Parent:GetFullName())
test = loadstring("b = 5")
print(location,test)

Here's my result:

nil function: 369C82A8

When I ran it without the test variable, it returned nil - Which is probably the same with the test variable. what I expected was workspace.Part for location and 5 for test.

Can someone please clarify loadstrings for me?

Thanks

1 answer

✓ Accepted answer

You recieved that output due to the fact that loadstring returns a function. You still have to call this function in order to play your code. What you did was created the function to call, and then printed it.

Try it this way;

loadstring("test = 5")()
loadstring("location = script.Parent:GetFullName()")()

print(test,location)

3 comments

0

Are the empty brackets Necessary?

1

Firstly, they are parenthasis - brackets look like this: []. Secondly, yes. That is how you call functions.

0

Since loadstring is returning a function, you call it again.

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