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

Does anybody know how to create a Data Shop?

Asked by 10 years ago

I have tried one for my game. Unfortunately, I do not have any code snippets to add. I'd really appreciate it if any of you ponder upon my question and create a script for me.

0
The name of the question is a little murky, I would appreciate if you would give a better explanation. HexC3D 830 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

You mean a data store? http://wiki.roblox.com/index.php?title=Data_store

Example:

local DataStore = game:GetService("DataStoreService"):GetDataStore("Points")
game.Players.PlayerAdded:connect(function(player)
    local key = "user_" .. player.userId
    --we want to give 50 points to users each time they visit
    DataStore:UpdateAsync(key, function(oldValue)
        local newValue = oldValue or 0 --oldValue might be nil
        newValue = newValue + 50
        return newValue
    end)
end)
Ad

Answer this question