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

How do I save Brick and Color3 Values? [EDITED]

Asked by
hiccup111 231 Moderation Voter
9 years ago

For some time I've been making a customizer script for my game

I've been working with JSON to save my tables, but it seems unable to encode or decode Color Values, and when the color values are in a table, they simply set to nil.

I'm using Data Persistence, since players may update and load their data many times in a session.

Does anyone know a work around?

Forgot to mention, I'm saving multiple colors at a time, stored in a table.

0
You should be able to save it as a string. Vrakos 109 — 9y
0
You'd think, but I'm getting either errors or nil values in return. hiccup111 231 — 9y

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Data Saving of either any doesn't play kindly with ROBLOX userdata.

The easiest way to save a Color3 is to convert it to a table:

local Color3Tab = {Color3.r, Color3.g, Color3.b}

Which will then easily save.

To get the Color3 back:

local Color3 = Color3.new(Color3Tab[1], Color3Tab[2], Color3Tab[3])
0
Works, Thanks hiccup111 231 — 9y
Ad

Answer this question