I was watching a tortorial and the scripts didnt work and i cant find new ones and im despreate. First i put the teams and make spawns that act like checkpoints. I add this scrpit in ServerScriptService.
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("ObbbyDataStore")
game.Players.PlayerAdded:Connect(function(player)
local data
local success, errorMessage = pcall(function()
data = DataStore:GetAsync(player.UserId.."-stage")
end)
if success then
print("Success")
if data then
player.Team = game.Teams[data]
else
player.Team = game.Teams.Stage1
end
else
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()
DataStoreService:SetAsync(player.UserId.."-stage",teamName)
end)
if success then
print("All went well")
else
print(errorMessage)
end
end)
And another script that has this code:
local checkpoints = game.Workspace:WaitForChild("Checkpoints"):GetChildren()
for i, checkpoint in pairs(checkpoints) do
checkpoint.TeamColor = game.Teams:FindFirstChild(checkpoint.Name).Teamcolor
checkpoint.BrickColor = game.Teams:FindFirstChild(checkpoint.Name).Teamcolor
end
