Welcome to the Forums!
Join thousands of other Roblox members with a free account.
Create Forum Account

Save checkpoint script not working

  • This website was created by Roblox members to replace the official forums (because Roblox shut them down) Join us if you like Roblox!

Quincitizens

New Member
Reputation: 0 / 0 / 0
Oct 22, 2019
23
3
3
Roblox
Quincitizens
Lua:
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:SetAsync(player.UserId.."-stage")
    end)   
    
    if success then
        print("Success")
        if data then
            player.Team = game.Teams[data]       
        else
            player.Team = game.Teams.Lobby
        end
    else
        print(errorMessage)
        player.Team = game.Teams.Lobby
    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 used this tutorial to save checkpoints in my obby game, but it is not working but no errors show up. Anyone knows what the problem is and how I can fix it?