First i put the teams and make spawns that have the teams names then i make the color same to the team color and turned off Neutral and turned on AllowTeamChangeOnTouch I also put the spawns into folders. I add this script in to ServerScriptService. (Only everything works BUT saving the players spot when leaving)
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("ObbyDataStore")
game.Players.PlayerAdded:Connect(function(player)
local data
local success, errorMessage = pcall(function()
data = DataStore:GetAsync(player.UserId.."-stasge")
end)
if success then
print("Success")
if data then
player.Team = game.Teams[data]
else
player.Team = game.Teams.Stage1
end
else
print(errorMessage)
player.Team = game.Teams.Stage1
end
player:LoadCharacter()
end)
game.Players.PlayerRemoving:Connect(function(player)
local teamName = player.Team.Name
local success, errorMessage = pcall(function()
DataStore:SetAsync(player.UserId.."-stage",teamName)
end)
if success then
print("All went well")
else
print(errorMessage)
end
end)
I don't get what is wrong.

3 comments
Maybe try it on published game instead of Studio Testing mode ?
OHHHHH
isn't this from AlvinBlox, because this is an exact copy...