Offline currency give Gui

Hi, I’m making some games where you can earn in-game currency and buy smth for it, and also transfer them to player (that was online) with 10% commission. But today I met the question: How can I make a Gui, where I (admin only) can give money in offline mode via DataStoreService? Thanks for your help (if it really helps)!

You’d need to read the player’s data by using GetAsync() with the key containing whatever you use to access the store (presumably UserId, other things wouldn’t be great tbh).

You could have a TextBox and a button of some kind, when the button is pressed use a RemoteEvent to tell the server the TextBox’s text (e.g. the player’s username) and then the server would need to get the player’s UserId.

Now, you might be wondering: “How do I get the offline player’s UserId?”
Well, the Players service has a very useful feature called GetUserIdFromNameAsync(). This sends a query to the Roblox website requesting the UserId of the given player. An example use:

local players = game:GetService("Players")
local playerId

--using a pcall() in case of spelling errors or other errors
local success, err = pcall(function()
    playerId = players:GetUserIdFromNameAsync(TextBox.Text)
end)
if success and playerId then
    print("Offline player's UserId: " ..playerId)
end
1 Like