why my script.lua file is not working

My script.lua file contains the following code and i want to stop users from deleting studies

function IncomingHttpRequestFilter(method, uri, ip, username, httpHeaders)
– Only allow GET requests for non-admin users

if username == ‘admin’ then
return false
else
return true
end
end

My orthanc.json file
has

“LuaScripts” : [ “C:\Orthanc\Script.lua”
],

and authentication is also enabled

“AuthenticationEnabled” : true,

What do you mean by “not working” ?
Have you tried adding a few print() in your lua script to make sure it’s being called ?
Have you checked in your logs that it is loaded correctly ?

In addition to Alain’s answer, there’s a section about this topic in the Orthanc Book:
http://book.orthanc-server.com/users/lua.html#filtering-incoming-rest-requests