Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I save TeamColor in DataStore?

Asked by 4 years ago

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)
0
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. killerbrenden 1537 — 4y
0
Are there any errors? mybituploads 304 — 4y
0
that's why he's using tostring mybituploads 304 — 4y
0
Try adding a print after you get the player data and see if it prints nil or the value you want mybituploads 304 — 4y
View all comments (3 more)
0
It's printing the Value that I want Bruno_GamerX 2 — 4y
0
The TeamColor change in the Player properties, but not in the Leaderboard Bruno_GamerX 2 — 4y
0
Maybe remove the BrickColor.new()? PrismaticFruits 842 — 4y

Answer this question