Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

RemoteEvents & RemoteFunctions altering arguments?

Asked by 4 years ago
Edited 4 years ago

So I've recently returned to Roblox Lua and have been working on a mini project involving some client-server communication. So far, the client will request some data from the server using a RemoteFunction and the server will respond with the corresponding table, simple enough right? The problem is during upon receiving the data, it appears to delete and alter any attribute keys with a value less than 1. Example:

Server (what is sent):

{
    [-1] = "Test1",
    [0] = "Test2",
    [1] = "Test3",
    [2] = {
        [0] = "Test4"
    }
}

Client (what is received):

 {
    [1] = "Test3",
    [2] = {
        ["0"] = "Test4"
    }
}

At first I assumed it was just a Lua thing caused by 1-based indexing, however before transmission the data is perfectly fine and readable. Anyone have any idea as to why this might be?

Edit: Another thing to note - removing the [1] attribute prevents the sub-1 elements from being removed, and turns all the keys into strings. Guess that kind of confirms the indexing theory, although it doesn't explain why the remotes are handling it so strangely.

1 answer

Log in to vote
0
Answered by 4 years ago

If I had to make a wild guess, it's probably some limitation with RemoteEvents, for example, you cannot have mixed strings and number as keys in a table. Your example should be quite easy to solve by simply changing all keys to strings.

0
Yeah that's what I've done for the time being. Was hoping there'd be a potential workaround to avoid the unnecessary overhead, and hassle. Thanks for the reply. doctor152 5 — 4y
Ad

Answer this question