#DataStore not saving other more then 2 IntValue

10 messages · Page 1 of 1 (latest)

vast nacelle
#

Heyo i have issue with my datastoring it wont save more then 2 which are Qi and Stamina other wont save no matter what i try i dont know if its fault in my script so i m seeking help.

local QiDataStore = DataStoreService:GetDataStore("Qi")
local StaminaDataStore = DataStoreService:GetDataStore("Stamina3")
local AgeDataStore = DataStoreService:GetDataStore("Age2")
local EprogressDataStore = DataStoreService:GetDataStore("Eprogress")
local TprogressDataStore = DataStoreService:GetDataStore("Tprogress")

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder", player)
    leaderstats.Name = "leaderstats"

    local Qi = Instance.new("IntValue", leaderstats)
    Qi.Name = "Qi"
    Qi.Value = 0
    
    local Stamina = Instance.new("IntValue", player)
    Stamina.Name = "Stamina"
    Stamina.Value = 0
    
    local Age = Instance.new("IntValue", leaderstats)
    Age.Name = "Age"
    Age.Value = 0
    
    local Eprogress = Instance.new("IntValue", player)
    Eprogress.Name = "Eprogress"
    Eprogress.Value = 0
    
    local Tprogress = Instance.new("IntValue", player)
    Tprogress.Name = "Tprogress"
    Tprogress.Value = 0

    local playerUserId = "Player_" .. player.UserId

    local success, qiData = pcall(function()
        return QiDataStore:GetAsync(playerUserId)
    end)

    if success and qiData ~= nil then 
        Qi.Value = qiData
    end```
#
        return StaminaDataStore:GetAsync(playerUserId)
    end)
    
    if success2 and staminaData ~= nil then
        Stamina.Value = staminaData
    end
    
    local success3, ageData = pcall(function()
        return AgeDataStore:GetAsync(playerUserId)
    end)
    
    if success3 and ageData ~= nil then
        Age.Value = ageData
    end
    
    local success4, eproData = pcall(function()
        return Eprogress:GetAsync(playerUserId)
    end)

    if success4 and eproData ~= nil then
        Eprogress.Value = eproData
    end
    
    local success5, tproData = pcall(function()
        return Tprogress:GetAsync(playerUserId)
    end)

    if success5 and tproData ~= nil then
        Tprogress.Value = tproData
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    local playerUserId = "Player_" .. player.UserId

    local QiValue = player.leaderstats.Qi.Value
    local StaminaValue = player.Stamina.Value
    local AgeValue = player.leaderstats.Age.Value
    local EprogressValue = player.Eprogress.Value
    local TprogressValue = player.Tprogress.Value```
#
        QiDataStore:SetAsync(playerUserId, QiValue)
        StaminaDataStore:SetAsync(playerUserId, StaminaValue)
        AgeDataStore:SetAsync(playerUserId, AgeValue)
        EprogressDataStore:SetAsync(playerUserId, EprogressValue)
        TprogressDataStore:SetAsync(playerUserId, TprogressValue)
    end)

    if not success then
        warn(errorMessage)
    end
end)

game:BindToClose(function()
    for _, player in ipairs(game.Players:GetPlayers()) do
        local playerUserId = "Player_" .. player.UserId

        local QiValue = player.leaderstats.Qi.Value
        local StaminaValue = player.Stamina.Value
        local AgeValue = player.leaderstats.Age.Value
        local EprogressValue = player.Eprogress.Value
        local TprogressValue = player.Tprogress.Value



        local success, errorMessage = pcall(function()
            QiDataStore:SetAsync(playerUserId, QiValue)
            StaminaDataStore:SetAsync(playerUserId, StaminaValue)
            AgeDataStore:SetAsync(playerUserId, AgeValue)
            EprogressDataStore:SetAsync(playerUserId, EprogressValue)
            TprogressDataStore:SetAsync(playerUserId, TprogressValue)
        end)

        if not success then
            warn(errorMessage)
        end
    end
end)```
#

this is whole script.

slate kayak
#

ok bro

you need to use tables

having that many datastores is very bad on roblox and you

as each datastore adds up in budget to read and write from so just please put your values in a table and save it that way

#

use one datastore, one table for your data

slate kayak
#

search tablea

#

you should be using tables for data stirages

#

learn them on google