Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 22 May 2016 01:02 PM |
this works, but when i try to run my functions on the client i just get and error saying the function is nil. (difficultySendback is not a valid member of module) etc
Server: local getAsset = game.ReplicatedStorage:WaitForChild('GetAsset') function getAsset.OnServerInvoke(player,asset) print(asset) local moduleScript = require(asset) print(moduleScript.difficultySendback) return moduleScript end
Client
local requireAsset = function(assetId) return game.ReplicatedStorage.GetAsset:InvokeServer(assetId) end local functions = requireAsset(418301137) |
|
|
| Report Abuse |
|
|
pketny
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 22 May 2016 01:06 PM |
Learn more about RemoteFunctions here:
http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial
"Limitations[edit] A table passed is cloned, with the clone losing its metatable if it was present. A table passed with both an array part and dictionary part will lose the dictionary part of it, similar to saving tables in a datastore. An instance that's only visible to the sender (local parts, descendants from the ServerScriptService, ...) will be replaced with nil." |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 22 May 2016 01:08 PM |
what im doing is stuff
local func = {}
func.test = function() end
return func
will this not work...? |
|
|
| Report Abuse |
|
|
pketny
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 22 May 2016 01:13 PM |
If you have both an array part and dictionary part it will not.
This array only has a dictionary part.
So in my logic, it would work. |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 22 May 2016 01:15 PM |
oh
so this would break it?
functions.difficultySendback = function(round) local characters = nil if 5 >= round and round >= 1 then characters = { math.min(5 * round), math.min(0 * round), math.min(0 * round), } elseif 10 >= round and round >= 6 then local round = round - 5 characters = { math.min(6 * round), math.min(4 * round), math.min(0 * round), } elseif 15 >= round and round >= 11 then round = round - 10 characters = { math.min(7 * round), math.min(5 * round), math.min(3 * round), } elseif 16 >= round and round >= 20 then round = round - 15 characters = { math.min(5 * round), math.min(7 * round), math.min(5 * round), } elseif 25 >= round and round >= 21 then round = round - 20 characters = { math.min(2 * round), math.min(8 * round), math.min(7 * round), } elseif 30 >= round and round >= 26 then round = round - 25 characters = { math.min(0 * round), math.min(10 * round), math.min(10 * round), } end return characters end |
|
|
| Report Abuse |
|
|
pketny
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 22 May 2016 01:17 PM |
| If that was your entire module, I would say not. |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 22 May 2016 01:19 PM |
| No, there's a ton of functions. |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 22 May 2016 01:23 PM |
| cutting that function and moving it client side by default. As long as most of it is private :/ |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 22 May 2016 01:24 PM |
| nvrm now i cant get my startRound function, what is going on |
|
|
| Report Abuse |
|
|
pketny
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 22 May 2016 01:24 PM |
I just tested, and that would break it.
It probably has something to do with "A table passed is CLONED, with the clone losing its metatable if it was present." |
|
|
| Report Abuse |
|
|
pketny
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 22 May 2016 01:25 PM |
| Your entire module will break once passed through a remotefunction. |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
| |
|
pketny
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 22 May 2016 01:28 PM |
| Put the ModuleScript in the ReplicatedStorage and require it client-sided |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
| |
|
pketny
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 22 May 2016 01:33 PM |
Make a module private like this:
http://wiki.roblox.com/index.php?title=Private_module
One way or another the data has to be copied to the client.
Putting it in the serverstorage won't make it less private than in the replicatedstorage.
|
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 22 May 2016 01:35 PM |
| That's what im doing, and you can't require those on the client so im requiring i on the server |
|
|
| Report Abuse |
|
|
pketny
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 22 May 2016 01:37 PM |
ModuleScript in the ReplicatedStorage:
local module = {}
module.a = function() print("a") end
return module
LocalScript in the StarterPlayerScripts:
require(game:GetService("ReplicatedStorage").ModuleScript).a()
Client output when server has started with 1 player, with FilteringEnabled or not:
20:37:00.606 - ! Joining game '00000000-0000-0000-0000-000000000000' place 0 at localhost 20:37:00.630 - Connecting to localhost:53640 20:37:00.633 - Connection accepted from 127.0.0.1|53640
a |
|
|
| Report Abuse |
|
|
|
| 22 May 2016 01:38 PM |
took this from glib for i, obj in next, script:GetChildren() do if obj:IsA'ModuleScript' then Lib[obj.Name] = require(obj) end end
setmetatable(Lib, { __index = function(t, index) if index == 'Script' then local sc = script:Clone() sc.Name = 'GLib' return sc end if type(index) == 'string' then local module = script:FindFirstChild(index) if module then Lib[module.Name] = require(module) end end return rawget(Lib, index) end, __call = function(t) return t.Script end })
https://www.roblox.com/waifu-item?id=405537969 |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 22 May 2016 01:43 PM |
| Guys I'm trying to hide the code from the person who will own the game as a safety measure for myself. |
|
|
| Report Abuse |
|
|
pketny
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 22 May 2016 01:46 PM |
You can gain the knowledge how to do this by reading this article that I also linked in an earlier reply:
http://wiki.roblox.com/index.php?title=Private_module
Nothing else (like requiring the ModuleScript server-sided) will accomplish that |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 22 May 2016 01:50 PM |
| Pkenty, I already told you, I am clearly requiring a private module on the server. I know what a private module is. This is what im doing. |
|
|
| Report Abuse |
|
|
pketny
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 22 May 2016 01:51 PM |
You seem to misunderstand.
Just place the modulescript inside of the ReplicatedStorage and require it with a localScript if you want it client sided. |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 22 May 2016 01:53 PM |
| so require the private module in replicated and then require that on the client? |
|
|
| Report Abuse |
|
|
pketny
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 22 May 2016 01:57 PM |
No.
Put the ModuleScript inside of the ReplicatedStorage. require it from a LocalScript like such:
local module = require(game:GetService("ReplicatedStorage").NAMEOFMODULESCRIPT) |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 22 May 2016 01:58 PM |
| I know how to do that, I'm trying to hide it from the person who owns the game... |
|
|
| Report Abuse |
|
|