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

How do I connect a name/id to a table, so I can access them both?

Asked by 7 years ago

Basically if I save something into a table, I'd need to know the name of it + the asset id so I can put it in the players inventory labeling it the name.

How can I do this?

Example;

ds= game:GetService("DataStoreService"):GetDataStore("Example")

local rolled= game.ReplicatedStorage.RolledSomething

rolled.OnServerEvent:Connect(function(plr, name, id)
    local skins= {}
    ds:SetASync() -- How to add both to the table?
end)

This is for a skin script, so players can change their assets skin texture

1 answer

Log in to vote
0
Answered by 7 years ago

Use table.insert, or just do this:

    local skins = {name, id}
    ds:SetAsync(key, skins)

Though of note is that you shouldn't really be using SetAsync as it might overwrite some saved data. It's recommended to use UpdateAsync instead.

Ad

Answer this question