Can't Create Folder in Data



local ad = "players"
local ad_id = ply:SteamID64()

if file.Exists("AddonCheck/" .. ad .. "/" ..ad_id.. ".txt", "DATA") then

print("checked")

else

function AddOpenOnJoin(ply)
timer.Simple(3,function()
ply:ConCommand("AddCheck")
end)

end

hook.Add("PlayerInitialSpawn", "AddCheck", AddOpenOnJoin)

end



 local ad = "players"
    
    	function DataCheckOpen()
    		if not (file.IsDir("AddonCheck/" ..ad, "DATA")) then
    			file.CreateDir("AddonCheck/" ..ad, "DATA")
    		end
    	end

DataCheckOpen()


I made this as just a sloppy test script for a bigger idea I had but cant create the directory for some reason. Any ideas?

You need to make sure you create the AddonCheck directory first, then create the subdirectory for players.