#Don't know if datastore is working properly

24 messages · Page 1 of 1 (latest)

vivid slate
#
local DSS = game:GetService("DataStoreService")

local Players = game:GetService("Players")

local SettingStore = DSS:GetDataStore("SettingsDataStore")

local SDSEvent = game.ReplicatedStorage.SettingEvent -- Settings DataStore remote event for communicating with local script and to recive events from it.

local StarterSettings = {
    MasterVolume = 2,
    Resolution = 2
}

Players.PlayerAdded:Connect(function(player)
    local PlayerSettings
    local success, fail = pcall(function()
        PlayerSettings = SettingStore:GetAsync(player.UserID)
    end)
    if not success then
        print("Failed to load Player Settings")
        player:Kick("Failed to load DataStore, Error1. If occurs multiple times, report it.")
    end
    if PlayerSettings then
        print("Player has settings")
    else
        SettingStore:SetAsync(player.UserId, StarterSettings)
    end
end)
wintry leafBOT
#

studio** You are now Level 5! **studio

vivid slate
#

Um

#

Studio's datastores are known for being buggy

#

So you could try just uploading your place privately

#

And trying it on therr

#

Anyway what errors did you get @stuck tusk

stuck tusk
#

none

#

There is the problem

vivid slate
#

Ok

#

Uh

#

So it failed to load

#

But had no errors?

stuck tusk
#

That's why I'm writing here

#

If it had any kind of error I cloud trace it back somehow

#

But how do you trace back something that doesn't exist

vivid slate
#

Welp gg

#

Idk man

split rock
#
local playerDataStore = DataStoreService:GetDataStore("STATS")

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "Values"
    leaderstats.Parent = player
    local values = {}
    for _, name in ipairs({"Tix", "Rebirths", "Tokens", "ClickUpg", "ClickUpgCost", "Ascends", "Multi", "MultiUpg", "MultiUpgCost", "GPMulti"}) do
        local value = Instance.new("IntValue")
        value.Name = name
        value.Parent = leaderstats
        values[name] = value
        if value.Name == "ClickUpgCost" then
            value.Value = 50
        elseif value.Name == "Rebirths" then
            value.Value = 1
        elseif value.Name == "Multi" then
            value.Value = 1
        elseif value.Name == "Ascends" then
            value.Value = 1
        elseif value.Name == "MultiUpgCost" then
            value.Value = 1000
        end
    end
    local success, data = pcall(function()
        return playerDataStore:GetAsync(player.UserId)
    end)
    if success and data then
        for name, value in pairs(values) do
            value.Value = data[name] or 0
        end
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    local values = {}
    local leaderstats = player:FindFirstChild("leaderstats")
    if leaderstats then
        for _, value in ipairs(leaderstats:GetChildren()) do
            if value:IsA("IntValue") then
                values[value.Name] = value.Value
            end
        end
        playerDataStore:SetAsync(player.UserId, values)
    end
end)``` mine is broken too 💀 won't save nun but it's not giving any errors
#

i blame roblox

#

this the same script ive used before that worked in one of my other games