file.write don't work

Hi !

I want use file.write but this don’t work, and i haven’t error lua

if(file.Exists( "mission/" .. LocalPlayer():UniqueID().. ".txt" ,"DATA")) then 
	--Detect if player have start job
	chat.AddText(Color(51, 102, 255, 51), "Abdel Kalif: ",Color(255,255,255), "Va faire ce que je t'ai demander, Amine Hamdou t'attends à la sortie d'un tunnel !" )

	--Proposes job

	local panel2 = vgui.Create( "DPanel", MissionF );
	panel2:SetSize( 890, 365 )
	function panel2:Paint( w, h )
	local item1 = vgui.Create( "DLabel",panel2 )
	item1:SetText( "Toi là, j'ai un petit boulot à te proposer !
Tu peux transmettre cette enveloppe à mon cousin ?" )
	item1:SetContentAlignment( 8 )
	local Commencer = vgui.Create( "DButton",panel2 )
	Commencer:SetText("Accepter cette mission !")
	function Commencer:DoClick() 
	chat.AddText(Color(0,102,0), "Vous avez reçu une enveloppe scellée !" )
	chat.AddText(Color(51, 102, 255, 51), "Abdel Kalif: ",Color(255,255,255), "Transmet cette enveloppe à Amine Hamdou qui se trouve à la sorti d'un tunnel!" )

--Here >
	file.Write("mission/"..LocalPlayer():UniqueID()..".txt", "1") 

Thank for help !

[editline]26th March 2016[/editline]

And i think :

if(file.Exists( "mission/" .. LocalPlayer():UniqueID().. ".txt" ,"DATA")) then 

Don’t work too

use print(whatever) to pinpoint where it’s going wrong

Also, where are you writing the file? To your gmod server or the local client? If file.exists is used clientside, it’s going to check in the client’s local /data folder so make sure that’s not the problem

Add at the top of your code. You must create folder at first.

if not file.Exists('mission', 'DATA') then

In my gmod server, but i need file.write before and file.write don’t work

i need file.write :cry: for dev my addon

That code looks like it’s clientside, so I have no idea why you are looking at your server files for the .txt files you write ON THE CLIENT.

How write on the server ? :wavey:

by executing the code serverside

The next error posted is going to be “attempt to index global ‘vgui’ (a nil value)”