Command run on a user not ingame

Hello, I want to run this:

game.Players.X:WaitForChild("UserData").Currency.Value = 100

X = The Player
However X is not ingame. How would I go around this.

If they are in a different game, you can use MessagingService.

Otherwise, you could update their data store with the new data. You just need the key to access their data.

pcall(ds.UpdateAsync, ds, key, function(old)
    old.Money.Value = 100 --example
    return old
end)

Can you provide it using my game.Players.Rapid_Gaming22:WaitForChild("UserData").Currency.Value = 100 also I am looking for a solution rather than scripts.

I can’t provide the entire system for you. Even then, on your post creator it literally says “please do not ask people to design/write entire systems for you”.

Here’s a quick example:

local msgService = game:GetService("MessagingService")
local players = game:GetService("Players")
local httpService = game:GetService("HttpService")

local function onMessageRecieved(data) --receive message
	local name = string.split(data.Data, "\"")[2]
	local player = players:FindFirstChild(name)
	if player then
		--do stuff
	end
end

local function sendMsg(playerName) --send message
	local rawData = playerName
	rawData = httpService:JSONEncode(rawData) --not sure if this is necessary
	local success, result = pcall(msgService.PublishAsync, msgService, "Example", rawData)
	if not success then
		warn(result)
	end
end

msgService:SubscribeAsync("Example", onMessageRecieved)

Will this allow me to do it as a command not in studio?

If you call the send procedure, you won’t need studio to run it. You just need something to run this code and a seperate way to take in the user.

Like I said, that will only work on a player playing your game. You could access their data using their data key. For example:

local players = game:GetService("Players")
local store = game:GetService("DataStoreService"):GetDataStore("StoreHere")

local success, userId = pcall(players.GetUserIdFromNameAsync, players, --[[username of player]])
if success and userId then
    local key = "Prefix_"..UserId
    local success2, data = pcall(store.GetAsync, store, key)
    if success2 and data then
        data.Money += 100
        local success3, result = pcall(store.UpdateAsync, store, key, function(old) return data end)
        if not success3 then warn(result) end
    end
end