To keep it short, I’m working on a Piggy game. And I ran into an issue with my code, where the error stated, “DataStoreService: CantStoreValue: Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters. API: SetAsync, Data Store: Saves”.
--Setup--
--Services--
local ServerStorage = game:GetService("ServerStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
--Remotes--
local Remotes = ReplicatedStorage:FindFirstChild("Remotes")
--Values--
local DataStore = DataStoreService:GetDataStore("Saves", "Saves")
--local NumPlrs = 0
--local NumberPlayers = 0
--local Mode = ""
--Stored--
local UI = ReplicatedStorage:FindFirstChild("UI")
--Module Functions--
--local Intermission = Round.Intermission()
---------
--Main Code--
local PlrAdded = Players.PlayerAdded:Connect(function(plr)
local Values = ServerStorage.Stored.Values:Clone() or DataStore:GetAsync(plr.UserId, "Saves")
Values.Parent = plr
end)
local PlrLeaving = Players.PlayerRemoving:Connect(function(plr)
DataStore:SetAsync(plr.UserId, plr:FindFirstChild("Values"))
end)
-------------
I want to save the folders because it would just be easier and more straight-foward than making a mile-long table for a player’s skins. Is there any other way?
Edit: Sorry for the commented-out code, I just copied the main round script because I was lazy.