#[DATASTORE2] I can't reset the data

18 messages · Page 1 of 1 (latest)

spare vortex
#

Hello! I used datastore2 to save data in my game, Now I want to reset the data for everyone. I tried changing the unique key but nothing works. The data never changes- It's like cached or something


game.Players.PlayerAdded:Connect(function(player: Player) 
    
    Remotes.LoadingEvent:FireClient(player, "Show", true)


    local loaded = Instance.new("BoolValue")
    loaded.Name = "Loaded"
    loaded.Parent= player
    
    local canPickup = Instance.new("BoolValue", player)
    canPickup.Name = "canPickup"
    canPickup.Value = true


    
    DataStore2:Combine(uniqueDataKey,{"Plot", "Upgrades", "Codes"})
    
    
    local Values = Instance.new("Folder", player)
    Values.Name = "Values"    
    
    local leaderstats = Instance.new("Folder", player)
    leaderstats.Name = "leaderstats"


    for valueName, valueData in config.Values do
        
        local storedData = DataStore2(valueName, player)
        local value:NumberValue = Instance.new(valueData.InstanceType)
        value.Value = storedData:Get(valueData.DefaultValue)
        value.Name= valueName
        value.Parent = Values
        
        DataStore2:Combine(uniqueDataKey, valueName)
        --print(storedData:IsBackup()) -- will print "true" if DataStore2 couldn't successfully get the data

        local leaderstatVal 
        if valueData.showLeaderstats then
            leaderstatVal= value:Clone()
            leaderstatVal.Parent = leaderstats
        end
        
        storedData:OnUpdate(function(newValue)
            value.Value = newValue
            if leaderstatVal then leaderstatVal.Value = newValue end
            if typeof(newValue)== "number" and newValue >= 1000 then
                if not BadgeService:UserHasBadgeAsync(player.UserId, config.Badges["1K Sales"]) then
                    BadgeService:AwardBadge(player.UserId, config.Badges["1K Sales"])
                end
            end
            if  typeof(newValue)== "number" and newValue >= 100000 then
                if not BadgeService:UserHasBadgeAsync(player.UserId, config.Badges["100K Sales"]) then
                    BadgeService:AwardBadge(player.UserId, config.Badges["100K Sales"])
                end
            end
            if  typeof(newValue)== "number" and newValue >= 1000000 then
                if not BadgeService:UserHasBadgeAsync(player.UserId, config.Badges["100M Sales"]) then
                    BadgeService:AwardBadge(player.UserId, config.Badges["100M Sales"])
                end
            end
        end)
    
        
    end
    
    for valueName, valueData in config.Unsaved do

        local storedData = DataStore2(valueName, player)
        local value:NumberValue = Instance.new(valueData.InstanceType)
        value.Value = valueData.DefaultValue
        value.Name= valueName
        value.Parent = Values
        
        local leaderstatVal 
        if valueData.showLeaderstats then
            leaderstatVal= value:Clone()
            leaderstatVal.Parent = leaderstats
        end
        
        if leaderstatVal then
            value:GetPropertyChangedSignal("Value"):Connect(function()    
                 leaderstatVal.Value = value.Value
            end)
        end
        
    end

    warn(DataEditor.get(player, "Plot"))
    require(Modules.Player)(player)
    Upgrades.UpdateUpgrade(player)
    
    repeat wait() until player:HasAppearanceLoaded()    
    
    AssignPlot(player)
    loaded.Value = true
        --Remotes.TutorialEvent:FireClient(player, "Start")
    
end)
bleak bloom
#

change datastore name

spare vortex
snow saffron
#

the main

#

datastore key

spare vortex
#

I tried changing it

#

The uniqueDataKey

snow saffron
#

show ur datastore2

#

variable

spare vortex
woeful elbow
#

@spare vortex If you want to reset data, you can use the DataStore Editor Plugin.

||Its not Expensive.||

https://devforum.roblox.com/t/datastore-editor-v3/716915

spare vortex
woeful elbow
spare vortex
woeful elbow
#

I'm just saying, if you want to keep the same key, and remove data, use the plugin.

spare vortex
#

But datastore2 is acting weird- I tried changing the main key. It's not updating it at all

snow saffron
#

datastore 2 is ass eitherway