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

W002: Global 'loadfile' is deprecated ?

Asked by 9 years ago

This is my script:

file = loadfile("C:/local.lua")
file()

I coped this from the roblox Function dump/Functions specific to Roblox and only changed the file to load but when I run the script I get an error "An error occured" and an error line under the word 'loadfile' in the script editor - error: W002: Global 'loadfile' is deprecated. Is there a way to fix this?

0
Nope. It's at a higher context for a reason. Scriptury 70 — 9y

1 answer

Log in to vote
-1
Answered by 9 years ago

loadfile() was replaced by require() and its not used like that you need to give it a directory like script.Parent or game.ServerScriptService.Script here is how you would use the new one

In ModuleScript which is in the same directory of the regular script named "ModuleScript"

function module()
    print("Congratulations you used this correctly")
end
return module

In regular script located in the same directory of the module script

local file=require(script.Parent.ModuleScript)
file()
0
What was wrong about my statement? nstrike159 15 — 9y
0
I was asking about loading a file that is in my system drive not about module scripts, but I did not downvote your reply. CodeSponge 125 — 9y
Ad

Answer this question