Tables or actual objects in explorer?

So basically, I’ve set up the tables my players are gonna need in-script and not objects and like now simple tasks like removing something from a table is really hard and I have to make tons of for loops to get where I need to and it’s just harder to access stuff because I need to find the table then when i find the table i need to find its index then when i find its index i need to unpack the table of that table and it’s honestly just really too much, and I’m thinking of just switching to the object style like having folders and values

This is currently how I have my stuff setup

To me at least, I only use objects when the client actually needs to access them, other than that it’s tables.
Tables are much easier to use than objects, tables are much faster and more organized.

What does that even mean? if there are actual issues with you getting player data especially from a table then there is something seriously wrong with your server/data structure and you should consider reworking it (which I guess is what you’re planning to do).
Indexing with tables couldn’t be any easier:

Player A wants to equip Item X → Player A Data.Inventory.Items[X’s ID] - Doesn’t exist = don’t equip, else equip.

Again, I personally prefer tables over Roblox objects with the exception of the client needing to actually access that specific data, but it really comes down to preference.

I personally recommend using tables for storing player data over objects.

It’s not difficult at all to reference stuff inside tables, as you can reference them the same way you would with objects.

That table you have for example, you can get the player’s items like so:
PlayerData[plr.UserId].Inventory.Items[1]

1 Like

Yeah im having alot of trouble access different data that I put in those tables and its getting too complicated for my brain

This is what I have to do to access data like missions and like sometimes it says Im trying to index something with nil, something with a number, I know what the index and values are of a table its just Im using a table inside of a table inside of a table and its too confusing

Here is how many for loops I need to access a mission

1 Like

If you want to visualize your data, then that’s completely fine, but I don’t think you should make your whole system use objects.
It’ll end up being the same, either way you’ll end up having instead of a table for Inventory you’ll have a folder, and for Items, Uncomplete Missions, and Complete missions you’ll end up having them as sub folders under that folder.

I’m assuming that your UncompleteMissions and CompletedMissions are both dictionaries, I am not sure why you have to loop through dictionaries to access the missions, Like what’s that for? (the code you just posted)…

Also making it Object Oriented wouldn’t really make it “easier” per se, it’s still tables and you’ll still have to do the good ol’ indexing (which isn’t that bad at all).

Does making it object or table oriented easier to save data?

yes because then you can just save the whole table itself into datastore.

I personally use objects/instances. It makes it a lot easier to visualize and manage player data that way.

1 Like

Well you cant save a whole table on the values inside of it

Yeah im more a visual person and like I just want a way to actually see my data

you can, actually. that screenshot on the first post can be saved as is.

1 Like

Wait really? How would I do it could you send a code example, of how you would save it

PlayerDataStore:SetAsync(plr.UserId, theTable)

And with that piece of code it saves all the tables inside of the tables I have?

As long as the tables do not contain reference to objects or instances. They can only be numbers, strings, or booleans.

Well these are the data types I store for the mission, wait I never knew this was possible

EDIT: People always said you need to like JSONEncode a table to save it

DataStore does JSONEncode automatically.

Here is an example of a table that is perfectly fine to save directly into a player’s datastore:

local ExamplePlayerData = {
	Money = 100,
	Level = 10,
	Exp = 55,
	Stats = {
		HP = 250,
		Dmg = 50,
		Speed = 25,
		Kills = 9001,
		Deaths = 1337,
	},
	LoadOut = {
		Weapon1 = {
			Name = "Dominus Sword",
			Type = "Legendary",
		},
		Weapon2 = {
			Name = "Gold Gun",
			Type = "Rare",
		},
		Weapon3 = {
			Name = "Bronze Dagger",
			Type = "Common",
		},
	},
	MissionsDone = 16,
	TimePlayed = 777,
}

Are you sure thats not with actual objects in explorer

No you cant actually be serious… Ive always been told the way to save data that is a table is to jsonencode it or like save all the values or something

1 Like

Wait hold on, I’m going to try and save a whole table

EDIT : @Dev_Ryan You were right it literally save deverything thanks for the help!