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

currentTime is not a valid member of Folder?

Asked by 2 years ago

I am trying to get a Datastore. and when i try this:

local ds = game:GetService("DataStoreService"):GetDataStore("datastore") --not my real datastore name. just for privacy
game.Players.PlayerAdded:Connect(function(plr)
    wait()
    local plrkey = "id_"..plr.userId
    local save1 = plr.leaderstats.currentTime  --Change to your stat
    local save2 = plr.leaderstats.maxTime

    local GetSaved = ds:GetAsync(plrkey)
    if GetSaved then
        save1.Value = GetSaved[1]
        save2.Value = GetSaved[2]
    else
        local NumberForSaving = {save1.Value, save2.Value}
        ds:GetAsync(plrkey, NumberForSaving)
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    ds:SetAsync("id_"..plr.userId, {plr.leaderstats.currentTime.Value, plr.leaderstats.maxTime.Value})
end)

i get this error: 16:06:59.632 currentTime is not a valid member of Folder "Players.Sivan12345678.leaderstats"

please help :-:

0
datastore names does nothing with privacy, you dont need to change it back though, also could you show the source code of you cloning leaderstats into player? Xapelize 2658 — 2y
0
oh thats answered Xapelize 2658 — 2y

2 answers

Log in to vote
0
Answered by
rabbi99 714 Moderation Voter
2 years ago

You either haven't made currentTime or you have to wait for it to be there.

local ds = game:GetService("DataStoreService"):GetDataStore("datastore") --not my real datastore name. just for privacy
game.Players.PlayerAdded:Connect(function(plr)
    wait()
    local plrkey = "id_"..plr.userId
    local save1 = plr.leaderstats:WaitForChild("currentTime") --Change to your stat
    local save2 = plr.leaderstats.maxTime

    local GetSaved = ds:GetAsync(plrkey)
    if GetSaved then
        save1.Value = GetSaved[1]
        save2.Value = GetSaved[2]
    else
        local NumberForSaving = {save1.Value, save2.Value}
        ds:GetAsync(plrkey, NumberForSaving)
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    ds:SetAsync("id_"..plr.userId, {plr.leaderstats.currentTime.Value, plr.leaderstats.maxTime.Value})
end)

0
but now there is Infinite yield possible on 'Players.Sivan12345678.leaderstats:WaitForChild("currentTime")' Sivan12345678 -5 — 2y
0
its still not working .. Sivan12345678 -5 — 2y
0
It's most likely because you haven't made something called currentTime in the leaderstats. You can make it by doing local ct = Instance.new("Intvalue") ct.Name = "currentTime" ct.Parent = "leaderstats" rabbi99 714 — 2y
0
i have. Sivan12345678 -5 — 2y
0
but now the error is on game.Players.PlayerRemoving:Connect(function(plr) ds:SetAsync("id_"..plr.userId, {plr.leaderstats.currentTime.Value, plr.leaderstats.maxTime.Value}) end) Sivan12345678 -5 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

You need to create a new string value into leaderstats using a function called Instance.new as you do not have any variables inside of the leaderstats folder.

0
So No intvalue? Sivan12345678 -5 — 2y
0
No, for time you should use a string value NotFrindow 346 — 2y

Answer this question