local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local DefaultKeybinds = require(ReplicatedStorage.ModuleScripts.Shared.DefaultKeybinds)
local dataStore = DataStoreService:GetDataStore("Keybinds")
local function onPlayerAdded(player: Player)
local success, result = pcall(function()
dataStore:GetAsync(player.UserId)
end)
if not success or not result then
warn("Failed to retrieve client keybinds data; Resetting to default keybinds.")
dataStore:SetAsync(player.UserId, DefaultKeybinds)
print(dataStore:GetAsync(player.UserId))
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
So in the data store script, I am basically just printing to see if it actually set the dataStore properly, but then it does this error?
DataStoreService: CantStoreValue: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters. API: SetAsync, Data Store: Keybinds
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local DefaultKeybinds = require(ReplicatedStorage.ModuleScripts.Shared.DefaultKeybinds)
local dataStore = DataStoreService:GetDataStore("Keybinds")
local function onPlayerAdded(player: Player)
local success, result = pcall(function()
return dataStore:GetAsync(player.UserId)
end)
if not success or not result then
warn("Failed to retrieve client keybinds data; Resetting to default keybinds.")
local convertedKeybinds = table.clone(DefaultKeybinds)
for action, keybind in pairs(convertedKeybinds) do
for key, inputKey in pairs(keybind) do
convertedKeybinds[action][key] = tostring(inputKey)
end
end
dataStore:SetAsync(player.UserId, convertedKeybinds)
print(dataStore:GetAsync(player.UserId))
else
local playerKeybinds = result
for action, keybind in pairs(playerKeybinds) do
for key, inputKey in pairs(keybind) do
playerKeybinds[action][key] = Enum.UserInputType[inputKey]
end
end
print("Loaded keybinds for player:", player.UserId, playerKeybinds)
end
end
Players.PlayerAdded:Connect(onPlayerAdded)