[LUA] Trouble in finding files using file.find()

So I am trying to make a “plugins” system kinda like darkrp’s “modules” for my gamemode but the problem is… This is my first experience with file.Find().
The problem is… the plugins directories aren’t printed {print(“Shared plugin:” … “’” … v … “’” … “has been initlialized.”) etc.}.
I tried debugging and trying to find what’s going on but I couldn’t figure it out. I was even trying to change paths in include_valid_plugins that’s why there is “THIRDPARTY”. Thanks.

Here is my shared.lua



include_valid_plugins = file.Find( "battleroyale/gamemode/plugins/*.lua", "THIRDPARTY" )
PrintTable(include_valid_plugins)
print("YAY!")
for _,v in pairs(include_valid_plugins) do
	if string.Left(v, 3) == "sv_" then
		include(v)
		print("Serverside plugin:" .. "'" .. v .. "'" .. "has been initlialized.")
	end
	if string.Left(v, 3) == "cl_" then
		AddCSLuaFile(v)
		print("Clientside plugin:" .. "'" .. v .. "'" .. "has been initlialized.")
	end
	if string.Left(v, 3) == "sh_" then
		include(v)
		AddCSLuaFile(v)
		print("Shared plugin:" .. "'" .. v .. "'" .. "has been initlialized.")
	end
end
print("Done!")


when you’re doing the include you’re not adding the path that the files are in just the file itself.

Yes indeed, but on the wiki it says that the file.find() returns 2 tables the first one (that I am using) is the filename and the second is the file directory. https://wiki.garrysmod.com/page/file/Find

So what does v reply in the print?

Nothing.

iirc THIRDPARTY is for mounted materials/models, not .lua files. Use LUA or GAME.

I tried GAME because in wiki it was saying it’ll be starting/searching from “garrysmod/” but still didn’t worked. I didn’t used LUA because gamemodes don’t have “lua/” folders. But still I’ll try both again.

EDIT: LUA worked, but hella errors I’ll try to fix them.

EDIT2: I think it needs to be filepath, lemme tri again.

EDIT3: Now errors are gone but nothing is printing… wut .-. I’ll try the filename again and give the error here



Couldn't include file 'sv_spawning.lua' (File not found) (@addons/battle_royale/gamemodes/battleroyale/gamemode/shared.lua (line 12))
Serverside plugin:'sv_spawning.lua'has been initlialized.


You don’t need to have “addons/battle_royale/gamemodes/” in the path.

So what should I put there?

I misread the error. You need to append “battleroyale/gamemode/plugins/” to the start of the string.

Thank you it worked! +rep