TableValue

When I’m developing with ROBLOX, I often find that I’d enjoy a TableValue object, just like IntValues, StringValues, etc.

Pardon the short topic, but it’s pretty simple and self-explanatory. Thanks.

11 Likes

While I’m not sure of the feasability of this, it would be helpful. As of right now, I am just JSON’ing my tables and saving them in string values, when I find I need to do that.

4 Likes

I recognize as well that it may not be plausible or technically impossible for some reason, and if it is, I’d love to know.

What use cases are there for this?

Generally value containers are used for configurations or leaderstats, which don’t really have a need for a TableValue.

wot – people use value objects? What for?

This will never happen due to the logic behind Lua and keeping track of things.
The closest you’ll get is JSON.

I’ve experimented with a lua table encode/decoder. If you don’t really want to use JSON(for whatever reason), you can always use it. However, there may be cases where it might error or not work correctly. https://github.com/KirkyTurky/Lua-Encode-Decode/blob/master/main.lua

I’m sure that if ROBLOX were to implement something like this, they’d be storing it as JSON anyway - so you’re better off just using a StringValue + JSONEncode/JSONDecode instead of waiting for an object that’d essentially do the same thing.

Just require a ModuleScript which returns a table. Problem solved.

This ModuleScript is nice and works with anything.
(except client<>server or client<>client stuff)

local value = {}
return function(...)
if select("#",...) > 0 then
value = ...
end return value
end

There’s a small problem here - unlike numbers, strings and vectors, tables are not immutable, i.e. they’re not values.
How are they supposed to replicate?

I’d rather move away from these types of objects. They’re easily exploitable (without FilteringEnabled) and lead to messy coding practices.

I use them so I can use .Changed to interact with the value between scripts.

I use them so I can use .Changed to interact with the value between scripts.[/quote]

You could probably use bindables as an alternative.

I use them so I can use .Changed to interact with the value between scripts.[/quote]

NO DONT DO THAT

I use them so I can use .Changed to interact with the value between scripts.[/quote]

And anyone with a memory editor can interact with your scripts too. You should be using bindables and remotes.

I use them to create a highly network efficient server to clients replication system which would take many dozens of lines to recreate without value objects.

I use them to create a highly network efficient server to clients replication system which would take many dozens of lines to recreate without value objects.[/quote]

Explain?

If you really need this, how about a folder filled with value objects?

I use them to create a highly network efficient server to clients replication system which would take many dozens of lines to recreate without value objects.[/quote]

Explain?[/quote]

First of all, hooking .Changed is very efficient. Updating frame by frame is not, and can sometimes be more difficult to do than hooking .Changed.

Second, ROBLOX objects don’t replicate unless their data has changed. By creating what I call a “replicator,” a folder filled with value objects representing the transmittable data of an object. I can harmlessly update them as often as I like and it is network efficient because they don’t send the data to the clients unless it has changed.

It allows for easier debugging. “Why isn’t this working?” Just look right at the value.

If you’re doing networking right, and literally everything important is on the server, then it’s secure.