#data wont save

1 messages · Page 1 of 1 (latest)

solid sundial
#
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

local DataStore = DataStoreService:GetDataStore("NewerPlayerData")
local createLeaderstats = require(script.CreateLeaderStats)

Players.PlayerAdded:Connect(function(plr)
    createLeaderstats.LeaderstatsAsync(plr)
    
    local data
    local timeValue = plr:WaitForChild("leaderstats").Time
    while task.wait(1) do
        timeValue.Value += 1
    end
    
    local suc, e = pcall(function()
        data = DataStore:GetAsync(plr.UserId)
    end)
    
    if suc then
        timeValue.Value = data[1]
    else
        warn("Data failed to save.")
    end
end)

Players.PlayerRemoving:Connect(function(plr)
    local timeValue = plr:WaitForChild("leaderstats").Time

    local suc, e = pcall(function()
        DataStore:SetAsync(plr.UserId, timeValue.Value)
    end)
end)

game:BindToClose(function()
    for i, plr in Players:GetPlayers() do
        local timeValue = plr:WaitForChild("leaderstats").Time
        
        DataStore:SetAsync(plr.UserId, timeValue.Value)
    end
end)

dont know whats wrong with it either

#

first time dealing with datastores

#

not really though i just dont know how to use them

twin elm
gaunt galleon
#

Same

twin elm
#

Error is not beeing returned btw

#

Its Success, Data not Success, Err

solid sundial
acoustic steeple
solid sundial
#

can you get straight into the point

twin elm
#

Yeah ik that the variable name fosent have to be data, but he things an error medsage is beeing returned

acoustic steeple
#

what does it print

#

at first

twin elm
#

Scripting on phone is actual pain

acoustic steeple
#

oh

#

this is the issue

#

you got inf loop

#

😭

#

so it never loads '

#

@solid sundial

solid sundial
#

oh yeah mb

#

im just a bit clumsy today

#

specially the fact that i never got any ideas to script

#

@acoustic steeple how do you deal with productivity anyways

solid sundial
#

oh thank god it works now

solid sundial
acoustic steeple
#

i havent been in studio in 20d

#

so

#

im the last person you should ask

#

🔥

real geyser
hidden glen
#

@solid sundial

#

@solid sundial @solid sundial @solid sundial @solid sundial

#

@solid sundial @solid sundial @solid sundial @solid sundial