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

What is the best way to store a table?

Asked by 5 years ago
Edited 5 years ago

Hey Everyone! I was working on a game, and I wanted to store a table like this in a value:

{true,false,false,false,false,false}

I tried storing it in a String Value but it said it was not a string. What is the best way to store this so I can get the data inside by just doing:

data.Value[1]

I also need to be able to edit this value from the script, and to check if it is changed.

It would be amazing if you could help with this!

Thanks, Armacom03

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
5 years ago

Use a ModuleScript:

local module = {true,false,false,false,false,false}

return module

Now another script can use the info with the require function:

local data = require(game.ReplicatedStorage.ModuleScript)
print(data[1])
1
How do I set the module script's text with the other script? armacom03 15 — 5y
0
NO WAY GOULSTEMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM greatneil80 2647 — 5y
0
I missed you dude :o greatneil80 2647 — 5y
0
Would I just do ModuleScript.module = {true,false,false,false,false,false}? armacom03 15 — 5y
View all comments (6 more)
0
@armacom03 Simply `data[index] = value` Goulstem 8144 — 5y
0
@greatneil <3 <3 Goulstem 8144 — 5y
0
no heart for me or what are u kidding me User#19524 175 — 5y
0
@Goulstem I still don't understand. How would I format that code? And how would I change it from another script? armacom03 15 — 5y
0
@Goulstem I get the error `data is not a valid member of ModuleScript` armacom03 15 — 5y
0
@Goulstem Nevermind, I got it, but how would I detect if it's changed, like how you can do that with a value? armacom03 15 — 5y
Ad

Answer this question