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

Cannot store int datastore data stores can only accept valid UTF-8characters error how can i fix ???

Asked by 4 years ago
Edited 4 years ago

here is what the error says Cannot store int in data store. Data stores can only accept valid UTF-8 characters

local module = {}

local DataStore = game:GetService("DataStoreService"):GetDataStore("***********")

game.Players.PlayerAdded:Connect(function(plr)

local Folder = Instance.new("Folder") Folder.Name = "Person" Folder.Parent = plr

local Color = Instance.new("BrickColorValue") Color.Name = "Color" Color.Value = BrickColor.new("Pastel brown") Color.Parent = Folder

local SavedColor = DataStore:GetAsync(plr.userId .. "-Color") if SavedColor ~= nil then Color.Value = SavedColor end

end)

game.Players.PlayerRemoving:connect(function(plr) local id = plr.userId local ColValue = plr.Person.Color.Value DataStore:SetAsync(id.."-Color", ColValue)

end)

return module

0
Put your code in code blocks and I can try and help :) johndeer2233 439 — 4y
0
how do i put them in code blocks tekkerz_ninja 2 — 4y
0
there i did it tekkerz_ninja 2 — 4y
0
You did it on the first line next time what you do is place your question and info first then press the blue lua button. That will make a bunch of ~ inside of those paste your code and then just save it that will format it via codeblocks. johndeer2233 439 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

Ok, You can't save any Roblox instances in datastores. Correct me if wrong, Datastores will only accept tables, string, numbers, booleans etc... However, that does not mean you can't do what you're trying to do. You can actually just save these numbers in a table example would be

local newColor = ColorV.Value
local colorT = {newColor.r,newColor.g,newColor.b}

Once doing this, you can then save the table colorT under the given data key and retrieve it by using the table indexes upon loading the data.

Oh, Use pcalls in your data retrieving because sometimes data stores can fail and you don't want your script to stop working because of a failed data retrieve.

The wiki for datastores has pcalls implemented with datastore. Roblox API: Datastores

If this helps an upvote and solved would be appreciated. :)

  • Best Regards, - Syn
0
ok in the local colort = table rgb how would i implement that would i just say on leaving save the rgb in the table etc tekkerz_ninja 2 — 4y
0
So, when a player is leaving or when you choose to save you store the color3's value rbg in a table as shown above and save the table with that data instead then when loading it you can grab the values from the loaded table local colorR = loadedData[1] because we saved red in the first index of the table johndeer2233 439 — 4y
0
basically to answer your question, Yes. Store the rbg or the color3 value in the table then save the table instead johndeer2233 439 — 4y
0
Ah, you are using brickcolor values. Instead what you can do is grab the color3 from the brickcolor so take your colour and do thebrickColor.Color and then do what I did above johndeer2233 439 — 4y
0
ok ill try thank you for the help tekkerz_ninja 2 — 4y
Ad

Answer this question