Vexture
|
  |
| Joined: 27 Jan 2011 |
| Total Posts: 630 |
|
|
| 18 Apr 2015 02:10 PM |
I assume it requires a ModuleScript, but I kind of need it to play nice with localscripts. ;c
~fml |
|
|
| Report Abuse |
|
|
Juddily
|
  |
| Joined: 24 Aug 2008 |
| Total Posts: 4243 |
|
|
| 18 Apr 2015 02:12 PM |
There would be multiple ways to do this. The first and most simplest method would be a global variable:
_G.MyTable = {table,etc,stuff}
And in any script that needs to access said table:
ThisTable = _G.MyTable |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 18 Apr 2015 02:12 PM |
Where do people get the assumption that module scripts don't work with local scripts?
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
|
| 18 Apr 2015 02:13 PM |
Dependent on if you're using FilteringEnabled, but I assume so.
-- Module script v --
local tab = {}
local table = {} --enter your table stuff HERE
return table
-- server script v --
local ModScript = [modscriptlocation] local req = require(ModScript)
local table1 = req()
Should work. |
|
|
| Report Abuse |
|
|
Vexture
|
  |
| Joined: 27 Jan 2011 |
| Total Posts: 630 |
|
|
| 18 Apr 2015 02:13 PM |
Because they don't work like localscripts do. They work more like regular scripts that store things for the entire server. I want things to be local to the client.
~fml |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 18 Apr 2015 02:14 PM |
Obviously do not understand what a module is.
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
Vexture
|
  |
| Joined: 27 Jan 2011 |
| Total Posts: 630 |
|
|
| 18 Apr 2015 02:14 PM |
Crap, I'm not using filteringenabled. >.<
~fml |
|
|
| Report Abuse |
|
|
|
| 18 Apr 2015 02:14 PM |
But as second poster said, global functions are numero uno.
|
|
|
| Report Abuse |
|
|
Vexture
|
  |
| Joined: 27 Jan 2011 |
| Total Posts: 630 |
|
|
| 18 Apr 2015 02:15 PM |
Chimmihc, no need to be rude. I didn't ask for your criticism.
~fml |
|
|
| Report Abuse |
|
|
|
| 18 Apr 2015 02:15 PM |
| If you make a ModuleScript that returns a table, each client will have it's own version of that table, if 1 client modifies it, neither the other clients, nor the server will see that change. Just like if the server modifies it, none of the clients will see THAT change. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 18 Apr 2015 02:15 PM |
The irony.
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
Vexture
|
  |
| Joined: 27 Jan 2011 |
| Total Posts: 630 |
|
|
| 18 Apr 2015 02:15 PM |
I don't want to use a global table. I want this table to be able to work locally across multiple local scripts.
~fml |
|
|
| Report Abuse |
|
|
Vexture
|
  |
| Joined: 27 Jan 2011 |
| Total Posts: 630 |
|
|
| 18 Apr 2015 02:16 PM |
That's a good explanation, War. Thank you.
~fml |
|
|
| Report Abuse |
|
|
|
| 18 Apr 2015 02:17 PM |
| np, glad I could help out. |
|
|
| Report Abuse |
|
|
Juddily
|
  |
| Joined: 24 Aug 2008 |
| Total Posts: 4243 |
|
|
| 18 Apr 2015 02:17 PM |
`Locally, across multiple local scripts`
Yes, global tables will do that. You can use a RemoteEvent to update the table on the server for other clients to access. |
|
|
| Report Abuse |
|
|
Vexture
|
  |
| Joined: 27 Jan 2011 |
| Total Posts: 630 |
|
|
| 18 Apr 2015 02:18 PM |
"Locally across multiple local scripts" But wouldn't everybody else see that? qq
~fml |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 18 Apr 2015 02:18 PM |
| Local script in the players startergui and make _G. table in it? |
|
|
| Report Abuse |
|
|
Juddily
|
  |
| Joined: 24 Aug 2008 |
| Total Posts: 4243 |
|
|
| 18 Apr 2015 02:18 PM |
| If it is a dynamic table, with changing values that need to be edited and accessed by g, you can use RemoteEvents, that's the only sound way to update it. if it's static, and unchanging, using a global table shouldn't be a problem |
|
|
| Report Abuse |
|
|
Vexture
|
  |
| Joined: 27 Jan 2011 |
| Total Posts: 630 |
|
|
| 18 Apr 2015 02:20 PM |
Let me provide an explanation for the use of this table. This table would contain values of abilities owned by players within the game.
~fml |
|
|
| Report Abuse |
|
|
Juddily
|
  |
| Joined: 24 Aug 2008 |
| Total Posts: 4243 |
|
|
| 18 Apr 2015 02:20 PM |
| Vexture, im not sure what you're trying to say. If you want a table local to only the client, just make a table in your localscript. |
|
|
| Report Abuse |
|
|
Vexture
|
  |
| Joined: 27 Jan 2011 |
| Total Posts: 630 |
|
|
| 18 Apr 2015 02:21 PM |
But I want OTHER localscripts to be able to see and edit the table without other players ever seeing those changes unless they purchased an ability. qq
~fml |
|
|
| Report Abuse |
|
|
Juddily
|
  |
| Joined: 24 Aug 2008 |
| Total Posts: 4243 |
|
|
| 18 Apr 2015 02:21 PM |
Hang on, stop for a second, let's step back and sort out the conufsuion.
You want a table, that the client can edit. Other clients should be able to see these edits that are made by different clients.
Is this correct? |
|
|
| Report Abuse |
|
|
Vexture
|
  |
| Joined: 27 Jan 2011 |
| Total Posts: 630 |
|
|
| 18 Apr 2015 02:23 PM |
I want a table that a client can edit that no other client will ever see.
Basically it's a table of purchased "abilities."
Only the client should see this. Every client would have their own table.
If someone purchases an ability, that person would have that ability added to their "inventory of abilities" table. It's specific to that person only.
~fml |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Apr 2015 02:24 PM |
_G and ModuleScripts 'technically' work the same in the sense that _G exists on each different machine (if you understood memory you would know why) and when you require modulescripts, the results are cached on each different machine (see above point).
If you do _G.a = 5 from client 1, _G.a would NOT be 5 for client 2 BECAUSE _G.a only exists for client 1.
Such that if you do require(x) from client 1 and let's say it returns a table, that table is cached for that client whereas if client 2 required if after, it's a different table because require was not run on their machine. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Apr 2015 02:24 PM |
| Vex you either use _G or a ModuleScript that uses a table. |
|
|
| Report Abuse |
|
|