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

I need help with my data store script?

Asked by 10 years ago

I would put data store in the tags but there is only data persistence so yeah @mod. There is no error in the output and here the script is...

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"
    HighLevel=Instance.new("IntValue")
    HighLevel.Parent=plr
    HighLevel.Name="highlev"
    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)
0
I fail to see the necessity of the datastore. If there is no output odds are that chkptGroup = nil wazap 100 — 10y
0
Its a obby and I would like to save there highest achieved level so they can just skip to that level. GetSporked 5 — 10y

Answer this question