micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 07 May 2015 12:42 PM |
After much testing I've actually fixed quite a bit...
return function() if game.PlaceId==0 then local m ={} m.Blah = function() print('Hello World') end return m else print('Access Denied') return nil end end
There are so many ways you could go about this; from having a list of OwnerId to PlaceId's, just provides more security.
If you have any suggestions/comments please do ask! Also, here's the Server Script that I used to call from it,
local getAccess = require(script.Parent:WaitForChild("ModuleScript")) local module = getAccess() if module then module.Blah() else print('Fail') end |
|
|
| Report Abuse |
|
|
|
| 07 May 2015 12:49 PM |
return function() getfenv(2).script = game.Workspace.Terrain end
In a LuaSourceContainer:
require(ReferenceToModuleScript)() print(script.Parent) --> Workspace |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 07 May 2015 01:00 PM |
Basically you want to place the Module into Workspace from Terrain? This was only a test and that's why I had it parented to ServerScriptService.
If you'd like to make it a MainModule that's the original purpose from this... To upload it and use a ID. |
|
|
| Report Abuse |
|
|
|
| 07 May 2015 01:03 PM |
| No, what I did was make it so that anything that requires it and runs the functions, and then does script.Parent or otherwise, finds out that "script" actually represents Terrain. |
|
|
| Report Abuse |
|
|
gskw
|
  |
| Joined: 05 Jan 2013 |
| Total Posts: 1364 |
|
|
| 07 May 2015 01:07 PM |
Remember to prevent the script requiring from accessing your ModuleScript, look:
ModuleScript: return function(...) return ...; end -- Do something here Script:
local a = require(id); getfenv(a).script.Parent = workspace; game:SavePlace(); That would save your ModuleScript with its source to their place.
Workaround:
-- Grab everything you need to locals local script = script; local game = game; local string = string; return setfenv(function(...) return ...; end, {}); -- Returns a function with an empty environment
This is a signature. Recommended username: AdorableGskw |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 07 May 2015 01:20 PM |
So basically
return setfenv(function() if game.PlaceId==0 then
local m ={} m.Blah = function() print('Hello World') end
return m
else print('Access Denied') return nil end end, {}) |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
| |
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 07 May 2015 05:26 PM |
| Care to share what you believe is broken? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 07 May 2015 05:26 PM |
Mmhm.
Just do this: create local variables that reference all functions and nuke the environment of the modulescript. Also any "you-made" functions should be local |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 07 May 2015 05:27 PM |
| Oh, your function in there is trying to access Game and print, which wouldn't exist. |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 07 May 2015 05:28 PM |
I made a local variable announcing game.
Outside of the function
local game = game
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 07 May 2015 05:29 PM |
Uh I did
local function print(what) print(what) end |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 07 May 2015 05:31 PM |
| lol why not local print = print; ? |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 07 May 2015 05:32 PM |
Idk o.o
I didn't know you could use local print = print without the () |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 07 May 2015 05:35 PM |
I made the changes, here's the new update;
local Ranks = {["Ensign"] = 2778951,["Trooper"] = 2779022,["Guard"] = 3696354,["Scout"] = 3696359,["Vanguard"] = 3696407,["Operative"] = 6590416,["Commandant"] = 3696378,["Lieutenant"] = 3696381,["Captain"] = 7966298,["Supervisor"] = 7966312,["WarrantOfficer"] = 7343472}
local game = game local HttpService = game:GetService("HttpService") local print = print
return setfenv(function() if game.PlaceId == 240323636 or game.PlaceId == 224680637 then local m ={} m.PromoteUser = function(userId, Rank) local a = HttpService:GetAsync(Removed) return a end return m else print('Access Denied') return nil end end,{})
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 07 May 2015 05:36 PM |
functions act in the same way as tables in the sense you get a 'reference' to it. local print = print is perfect, no need to create a new prototype |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
| |
|