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

Why is my object disappearing from ReplicatedStorage?

Asked by 3 years ago

Hello, I tried doing a script to save datas on a table but something weird happens

a part of the script:

game.Players.PlayerRemoving:Connect(function(Player)
    local StatsValue = {}

    for _,v in pairs(game.ReplicatedStorage.Stats:GetChildren()) do
        print(v.HasGot.Value)
        local New = {['Material'] = v.Name, ['HowMuch'] = v.Value, ['Unlocked'] = v.HasGot.Value}
        table.insert(StatsValue,New)
    end
end)

And the value is actually printing "false" but when I want to insert it in "Unlocked" i get the error "HasGot is not a valid member of StringValue"

I don't understand why :(

1 answer

Log in to vote
0
Answered by 3 years ago

Well, I am not sure what is causing the HasGot not the member of StringValue. But, other from that, there is a major issue. You cannot add Dictionaries to the table using table.insert. the following code might help :

game.Players.PlayerRemoving:Connect(function(Player)
    local StatsValue = {}

    for _, v in pairs(game.ReplicatedStorage.Stats:GetChildren()) do
        print(v.HasGot.Value)
        StatsValue['Material'] = v.Name
        StatsValue['HowMuch'] = v.Value
        StatsValue['Unlocked'] = v.HasGot.Value
    end
end)

If the problem related to HasGot further continues, please comment and lemme know. If you want realtime help, you can ask for my discord DM.

0
My script is different, he dosen't work like that because there is multiple Stats so there is a lot of table inside of the same table, wich is then saved inside Datastores with JSONEncode. msdarckdu802 65 — 3y
0
Well, if you try to print the contents of the table, it will be in encoded form and it cannot be decoded. That is why, I suggested you this method. You can only use table.insert in arrays. BestCreativeBoy 1395 — 3y
0
Yes, but I don't think its the problem, because even if I print it again without adding it in a table or anything like that, it still diseapear like printing it would delete it msdarckdu802 65 — 3y
Ad

Answer this question