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

How to get object from Stored table in datastore, with variables?

Asked by 5 years ago
Edited 5 years ago

For example if I have such table, stored in datastore

table = {["money"] = 1000,
         ["House"] = {
                 ["Big"] = false,
                 ["small"] = true
                }
        }

and if I want to know if player has small house, I would normally just type

print(table.house.small)

but what I need to know is based on specific case of player, like somebody may have big house, somebody not, and one house can be small, one big.

But instead of placing individual scripts in all of those houses one by one, I want to do that with one script. For that, I'm placing string values in all houses and do something like that

local houseType = house.type.Value --type is string value placed in house
print(table.house.houseType)

But this gives me nill, cause it doesn't recognize the object stored in houseType variable. if you do

print(houseType)

it will print correct type of the house, either small or big, but when using this variable, it fails to associate the value of the variable to the one in table.

0
As, I mentioned before in another question, when making locals, NEVER EVER put.Value in it. I don't know why, but here's an example, local Banana = script.parent (NOT script.parent.Value) mixgingengerina10 223 — 5y
0
But then I have to put it in print, like print(table.house.houseType.value), but that will obviously cause an error because the one in table doesn't have value, value has GooierApollo664 183 — 5y

Answer this question