RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Create a team save script that saves a players team"
-- server script (ServerScriptService) local DataStoreService = game:GetService("DataStoreService") local teamDataStore = DataStoreService:GetDataStore("TeamData") game.Players.PlayerAdded:Connect(function(player) local success, team = pcall(function() return teamDataStore:GetAsync(player.UserId) end) if success and team then local teamColor = BrickColor.new(team) player.TeamColor = teamColor end end) game.Players.PlayerRemoving:Connect(function(player) local success, err = pcall(function() teamDataStore:SetAsync(player.UserId, player.TeamColor.Name) end) if not success then warn("Failed to save team for player " .. player.Name .. ": " .. tostring(err)) end end)