Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters. API: UpdateAsync, Data Store: PlayerStorenil

very confused on what this is, never had this issue before with data stores…

Save Function

local function Save(Player, OnShutdown)
	local Key = KeyPrefix .. tostring(Player.UserId)
	local Success, Error
	local Data = GetData(Player)
	
	if not Data then return end;
	
	--- Repeat ---
	
	repeat
		if not OnShutdown  then WaitForRequestBudget(Enum.DataStoreRequestType.UpdateAsync) end
		Success, Error = pcall(function()
			DataStore:UpdateAsync(Key, function(PreviousData)
				return Data
			end)
		end)
	until Success
	--- Error --
	if not Success then
		warn("Failed to save data" .. tostring(Error))
		return false
	end
	
	return true
end

*** Data Template ***

return {
	--- Direct Data ---
	Reputation = 0,
	Money = 0,
	
	Inventory = {
		Removable = {},
		Nonremovable = {}
	},
	
	Moves = {
		Removable = {},
		Nonremovable = {}
	},
	
	Multipliers = {
		Speed = 1,
		Agility = 1,
		Damage = 1,
		DamageReduction = 1,
	},
	
	--- Internal Data ---
	LastJoin = os.time(),
	PlayTime = 0,
	ClientSettings = {
		Keybinds = {
			Console = {
			Combat = {
				Moves = {
					["1"] = Enum.KeyCode.ButtonR1,
					["2"] = Enum.KeyCode.ButtonR2,
					["3"] = Enum.KeyCode.ButtonL1,
					["4"] = Enum.KeyCode.ButtonL2,
				},
				Basic = {
					["M1"] = Enum.KeyCode.ButtonB,
					["M2"] = Enum.KeyCode.ButtonR3,
					["Block"] = Enum.KeyCode.ButtonX,
					["Sprint"] = Enum.KeyCode.ButtonL3,
					["Dash"] = Enum.KeyCode.ButtonY,
					["SwapMoveset"] = Enum.KeyCode.DPadDown
				},
			
			},
			GUI = {
					["MainSettings"] = Enum.KeyCode.DPadRight,
					["Map"] = Enum.KeyCode.DPadUp,
					["Interact"] = Enum.KeyCode.DPadLeft
			}
			},
			Computer = {
				Combat = {
					Moves = {
						["1"] = Enum.KeyCode.One,
						["2"] = Enum.KeyCode.Two,
						["3"] = Enum.KeyCode.Three,
						["4"] = Enum.KeyCode.Four,
					},
					Basic = {
						["M1"] = Enum.UserInputType.MouseButton1,
						["M2"] = Enum.UserInputType.MouseButton2,
						["Block"] = Enum.KeyCode.F,
						["Sprint"] = Enum.KeyCode.LeftControl,
						["Dash"] = Enum.KeyCode.Q,
					},

				},
				GUI = {
					["MainSettings"] = Enum.KeyCode.P,
					["Map"] = Enum.KeyCode.M,
					["Interact"] = Enum.KeyCode.E
				}
			},
		},
		Misc = {
			Autorun = true,
			Autouse = true,
			LowQuality = false,
			NoTexture = false,
			NoVFX = false,
			Music = true,
			Sounds = true,
			
		}
	},
	--- Moderation Data ---
	BanData = {
		false, -- Is Banned?
		"", -- Reason
		"" -- Admin
	},
	--- Gamepass Data ---
	Gamepasses = {
		
	}
}

Roblox only allows you to save tables, strings, and numbers. The keycodes are the issue so convert them to a string

Example:

local MyKeyCode = Enum.Keycode.One

local DataToSave = {
 KeyCode = MyKeyCode.Name
}
1 Like

This + In the Load Function I accidentally set the Player’s loadeddata cache to the player itself lol

What about the keycodes? You cant save keycodes/enums to a datastore

the “This +” Part means, what you said plus extra sorry if it was confusing lol.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.