attempt to index global 'resource' (a nil value)

Hello gentlemen.

After the update all my scripts that has the following line in the beginning of the script:
[LUA]
resource.AddFile(“filepath/file.ext”)
[/LUA]

suddenly return this error:

[LUA]
[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_sg552/shared.lua:1: attempt to index global ‘resource’ (a nil value)

  1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_sg552/shared.lua:1
    [/LUA]

I know I can just use the Resourses.lua file and add them there, but I was just curious why the resource.AddFile command is suddenly returning errors.

Any ideas?

You’re running it clientside.

so just

[LUA]
if SERVER then
resource.AddFile(“path/file.ext”)
end
[/LUA]

then?

I don’t see why you would want resource.AddFile in a shared file anyway, but yeah that’d work.

Yeah, I think I’ll move them to resources.lua instead. Thanks for your help :slight_smile: