local DataStoreService = game.GetService("DataStoreService")
local DataStore = DataStoreService:GotDataStore("Obby DataStore")
game.Players.PlayersAdded:Connect(function(player)
local data
local sucess, errorMessage = pcall(function()
data = DataStore:GetASync(player.UserId.."=Stages")
end)
if success then
print ("success")
if data then
player.Team = game.Team[data]
else
player.Team = game.Team.Stage1
end
else
print (errorMessage)
player.Team = game.Teams.Stage1
end
player.LoadCharacter()
end)
game.Players.PlayerRemoving:Connect(function(player)
local team name = player.Team.Name
after pcalling if it fails you do not retry. This means if it fails once it just wont load at all