Hi, I’m trying to make it so that if a specific user joins, they will have 999,999 coins. Here is my code:
local DataStore2 = require(game.ServerScriptService.DataStore2)
local MarketplaceService = game:GetService("MarketplaceService")
local defaultCashValue = 0
game.Players.PlayerAdded:Connect(function(plr)
local coinsDataStore = DataStore2("Coins", plr)
local cash = Instance.new("StringValue")
cash.Name = "Cash"
local function coinsUpdated(updatedValue)
cash.Value = coinsDataStore:Get(updatedValue)
game.ReplicatedStorage.UpdateClientCurrency:FireClient(plr, coinsDataStore:Get(defaultCashValue))
end
coinsUpdated(defaultCashValue)
coinsDataStore:OnUpdate(coinsUpdated)
if plr.UserId == 34355831 then
coinsDataStore:Set(999999)
end
end)
local DataStore2 = require(game.ServerScriptService.DataStore2)
local MarketplaceService = game:GetService("MarketplaceService")
DataStore2.Combine("MainKey", "Coins")
local defaultCashValue = 0
game.Players.PlayerAdded:Connect(function(plr)
local coinsDataStore = DataStore2("Coins", plr)
local cash = Instance.new("StringValue")
cash.Name = "Cash"
local function coinsUpdated(updatedValue)
cash.Value = coinsDataStore:Get(updatedValue)
game.ReplicatedStorage.UpdateClientCurrency:FireClient(plr, coinsDataStore:Get(defaultCashValue))
end
coinsUpdated(defaultCashValue)
coinsDataStore:OnUpdate(coinsUpdated)
if plr.UserId == 34355831 then
local v = 99999
coinsDataStore:Set(v)
cash.Value = v
end
-- cash.Parent = player.leaderstats ?
end)