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

DataStore not working despite no errors?

Asked by 4 years ago
Edited 4 years ago

Hello,

My datastore is not saving anything and I am not getting any errors, I am stumped

Any help would be greatly appreciated. API is enabled in settings as well.

local Datastore = game:GetService("DataStoreService"):GetDataStore("DataValues")

game.Players.PlayerAdded:Connect(function(player)

    local Folder = Instance.new("Folder", player)
    Folder.Name = "StatData"

    local cR = Instance.new("IntValue", Folder)
    cR.Name = "cR"

    local cRBank = Instance.new("IntValue", Folder)
    cRBank.Name = "cRBank"

    local Ore = Instance.new("IntValue", Folder)
    Ore.Name = "Ore"

    local Iron = Instance.new("IntValue", Ore)
    Iron.Name = "Iron"

    local Silicon = Instance.new("IntValue", Ore)
    Silicon.Name = "Silicon"

    local Nickel = Instance.new("IntValue", Ore)
    Nickel.Name = "Nickel"

    local Titanium = Instance.new("IntValue", Ore)
    Titanium.Name = "Titanium"

    local Platinum = Instance.new("IntValue", Ore)
    Platinum.Name = "Platinum"

    local Palladium = Instance.new("IntValue", Ore)
    Palladium.Name = "Palladium"

    local Phosphorus = Instance.new("IntValue", Ore)
    Phosphorus.Name = "Phosphorus"

    local Notoriety = Instance.new("IntValue", Folder)
    Notoriety.Name = "Notoriety"

    local ShipObject = Instance.new("ObjectValue", Folder)
    ShipObject.Name = "Ship"


    local key = "User - " .. player.UserId

    local storeditems = Datastore:GetAsync(key)
    if storeditems then
        cR.Value = storeditems[1]
        cRBank.Value = storeditems[2]
        Ore.Value = storeditems[3]
        Notoriety.Value = storeditems[4]
    else
        local items = {cR.Value, cRBank.Value, Ore.Value, Notoriety.Value}
        Datastore:SetAsync(key, items)
    end 
end)

game.Players.PlayerRemoving:Connect(function(player)
    local items = {player.StatData.cR.Value, player.StatData.cRBank.Value, player.StatData.Ore.Value, player.StatData.Notoriety.Value}
    local key = "User-" .. player.UserId
    Datastore:SetAsync(key, items)
end)
0
player.userId needs to be player.UserId didnt read whole script but that's one thing that's gonna error royaltoe 5144 — 4y
0
Ah, gotcha. Decimaprism 65 — 4y
0
Are there any output errors royaltoe 5144 — 4y
0
No, none still. its weird, maybe Roblox finally just broke it. Decimaprism 65 — 4y
0
Still havent been able to find the problem, despite tons of editing, etc... Decimaprism 65 — 4y

Answer this question