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

Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters.?

Asked by 4 years ago

Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters. second script:

local ds = game:GetService("DataStoreService"):GetDataStore("Data")

game.Players.PlayerAdded:Connect(function(plr)
    local key = plr.UserId.."_id"
    local save = plr.stats.ins

    local savel = ds:GetAsync(key)
    if savel then
        save.Value = savel[1]
    else
        local nfs = {save}
        ds:GetAsync(key, nfs)
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    local key = plr.UserId.."_id"
    local save = plr.stats.ins
    ds:SetAsync(key, save)
end)

first script:

game.Players.PlayerAdded:Connect(function(plr)
    local folder = Instance.new("Folder", plr)
    folder.Name = "stats"

    local ins = Instance.new("NumberValue", folder)
    ins.Name = "ins"
    ins.Value = 1
end)

0
You are trying to save an instance, "save" which is ins whatever that is.. You can only save userdata values, not objects itself greatneil80 2647 — 4y

2 answers

Log in to vote
0
Answered by
iHavoc101 127
4 years ago

Second script:

local ds = game:GetService("DataStoreService"):GetDataStore("Data")

game.Players.PlayerAdded:Connect(function(plr)
    local key = plr.UserId.."_id"
    local save = plr.stats.ins

    local savel = ds:GetAsync(key)
    if savel then
        save.Value = savel[1]
    else
        local nfs = {save}
        ds:GetAsync(key, nfs)
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    local key = plr.UserId.."_id"
    local save = plr.stats.ins.Value
    ds:SetAsync(key, save)
end)

Fixed :D

0
iHavoc101 not working :( zer_00Y 2 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

script not save oh i was wrong but thank you

0
script not save zer_00Y 2 — 4y

Answer this question