Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

I need DataStore Help?

Asked by 9 years ago

Sorry for the long read but please, I need help :)

game.Players.PlayerAdded:connect(function(plr)
    local level = Instance.new("StringValue")
    level.Value = "lobby"
    level.Parent = plr
    level.Name = "Level"
    local chkpt = Instance.new("IntValue")
    chkpt.Parent = plr
    chkpt.Value = 0
    chkpt.Name = "Checkpoint"
    ID=plr.userId
    ds=game:GetService("DataStoreService"):GetDataStore("HighLevel")
    data=ds:GetAsync(ID) or ds:SetAsync(ID,{
        HighLevel=0;
    })
    plr.CharacterAdded:connect(function(char)
        local chkptGroup = Workspace:FindFirstChild(level.Value:sub(1, 1):upper() .. level.Value:sub(2):lower() .. "Checkpoints")
        if chkptGroup then
            print("Found " .. chkptGroup.Name)
            local spawn = chkptGroup:FindFirstChild(tostring(chkpt.Value))
            if spawn then
                print("Found spawn, " .. spawn:GetFullName())
                wait(.25)
                char:WaitForChild("Torso").CFrame = spawn.CFrame + Vector3.new(0, 4, 0)
            end
        end
    end)
end)

Answer this question