I'm trying to save the TeamColor of a Player when he leaves the game, but the Script isn't working, and I don't know the reason.
Script:
local DataService = game:GetService("DataStoreService")
local TeamData = DataService:GetDataStore("TeamStore")
game.Players.PlayerAdded:Connect(function(Plr)
local t = TeamData:GetAsync(Plr.UserId)
Plr.TeamColor = BrickColor.new(t)
end)
game.Players.PlayerRemoving:Connect(function(Plr)
local TeamColor = tostring(Plr.TeamColor)
TeamData:SetAsync(Plr.UserId, TeamColor)
end)

7 comments
You can't save UserData, you have to save it as a string or value or table. So save the name of the team color or team and load it by setting the player's team to that saved team, or to the brick colored team.
Are there any errors?
that's why he's using tostring
Try adding a print after you get the player data and see if it prints nil or the value you want
It's printing the Value that I want
The TeamColor change in the Player properties, but not in the Leaderboard
Maybe remove the BrickColor.new()?