|
| 18 Jan 2015 03:58 PM |
if you have a remote function and invoke it from the client and it returns a table with a metatable, the metatable doesn't persist.
this is ruining my game
--remote function script.Parent.OnServerInvoke = function(sender) return setmetatable({}, {}) end
--local script local x = workspace.RemoteFunction:InvokeServer() print(getmetatable(x)) --> nil
THIS IS RUINING MY GAME I HAVE TO REDESIGN MY WHOLE CLASS SYSTEM NOW WTF ROBLOX |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
| |
|
|
| 18 Jan 2015 04:00 PM |
| https://www.youtube.com/watch?v=tl2OzaVATXg |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2015 04:02 PM |
HOW TF DO I FIX THIS OMFG KYS ROBLOX
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Jan 2015 04:02 PM |
I don't think you can return a table from the server to the client since it doesn't exist in the client's memory.
Although maybe Roblox copies it to memory? To test this, print(x) and see if you get nil or not. |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2015 04:03 PM |
print(getmetatable(x)) --> nil print(x) --> table: 0xe37b7e0 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Jan 2015 04:05 PM |
| Well in any case, you might as well just return 2 tables and use setmetatable client-side. |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2015 04:05 PM |
im mad
my whole game is based on a class system that stores methods in the metatable |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2015 04:06 PM |
okay thanks cnt
i did that and it works
it's uglier, but oh well |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2015 04:38 PM |
omg i figured it out
remote functions return a copy of the table, not a reference
:((
--remote function script.Parent.OnServerInvoke = function(sender, array) return array end
--local script x = {} print(x == workspace.RemoteFunction:InvokeServer(x)) --> false |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Jan 2015 04:40 PM |
Well yeah, but I would assume a copy of the table would also include the MT D:
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Jan 2015 04:41 PM |
| A reference would practically impossible since the table only really existed on the server /cry |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2015 04:43 PM |
well here's the thing
i need to return the table from the server and be able to manipulate it from the server AND client
so when i change a number from the client, its not the same as changing it from the server
all the constants are the same, but anything that varies causes bugs D: |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Jan 2015 04:45 PM |
That's not possible, you would have to return the "altered" table and same with the metatable if you change that.
Think about it, on the server let's say our table started at 1F23456 yet on the client, that might be something completely different. So the server would have to copy the full table since a reference to 1F23456 on the client would point to something possible completely different.
|
|
|
| Report Abuse |
|
|
|
| 18 Jan 2015 04:46 PM |
ok thanks
here's the next question:
i plan on storing values in the server storage now
i want the model containing the values to be named with the current time (tick())
is it possible for the same time to return twice? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Jan 2015 04:49 PM |
Well, it depends.
For example: local x, y = tick(), tick(); x would (in theory) be equal to y.
However: print(tick()); print(tick()); Would be different since there is some delay while printing to the output. |
|
|
| Report Abuse |
|
|
Koufasa
|
  |
| Joined: 07 Jun 2008 |
| Total Posts: 482 |
|
|
| 02 Apr 2015 12:46 AM |
| Same issue here with metatables. Any way around this? |
|
|
| Report Abuse |
|
|
|
| 02 Apr 2015 12:53 AM |
| Why do you need to send the table to begin with? Can't you just make modifications server-side then push them to the client? |
|
|
| Report Abuse |
|
|
Koufasa
|
  |
| Joined: 07 Jun 2008 |
| Total Posts: 482 |
|
|
| 02 Apr 2015 12:58 AM |
Here's my issue:
The client wants to get the properties of an object. The properties are stored in a metatable server-side. The client sends a request to the server asking for the properties. The server returns the metatable, however when the client tries to access the properties, we end up with an error because we can't find them. |
|
|
| Report Abuse |
|
|
|
| 02 Apr 2015 02:28 AM |
"but I would assume a copy of the table would also include the MT D:" Thanks a million, now I need to go through every script I have ever written in my gigabyte Roblox folder and see if any of them copy tables, just so I can modify it to copy metatables too. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 02 Apr 2015 02:33 AM |
| Joking. Until a few months ago, I didn't even know that tables were only referenced. |
|
|
| Report Abuse |
|
|