I'm trying to make a DataStore to save data, but it keeps on giving me an error saying 104: Cannot store int in data store. Data stores can only accept valid UTF-8 characters.
This is the script:
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("PlayerTeamData")
Players.PlayerAdded:Connect(function(player)
local playerName = tostring(player.Name)
local key = "player-"..player.UserId
local data
local success, errorMessage = pcall(function()
data = DataStore:GetAsync(key)
end)
if success then
if data then
print(playerName.."'s".." data has been loaded.")
player.Team = Teams[data]
end
else
warn("Unable to load "..playerName.."'s ".."data.")
warn(errorMessage)
end
end)
Players.PlayerAdded:Connect(function(player)
local playerName = tostring(player.Name)
local key = "player-"..player.UserId
local success, errorMessage = pcall(function()
DataStore:SetAsync(key, player.Team)
end)
if success then
print(playerName.."'s".." data has been saved.")
else
warn("Unable to save "..playerName.."'s ".."data.")
warn(errorMessage)
end
end)

2 comments
What is TeamColor's classname?
I meant to say player.Team = Teams[data] instead of player.TeamColor*