Game:BindToClose(EconomyAnalytics)

Hello everyone,

I’m making a paycheck system into my game and need to pay players (increase their DataStore coins) when the game closes. I got analytics code from the Roblox website, but I don’t know what I should write instead of the player because I only got their UserId. Players:GetPlayerByUserId(UserId) does not return the player when the player is offline and wants a specific player type.
My paycheck system works like this: Every x minutes give all players a paycheck.

AnalyticsService:LogEconomyEvent(
	???, --The player goes here, but I've got no player
	Enum.AnalyticsEconomyFlowType.Source,
	"Coins", -- Currency name
	Paycheck, -- Amount earned
	PlayerCoins, -- Current balance
	Enum.AnalyticsEconomyTransactionType.Gameplay.Name, -- Transaction type
	job -- Name of the job
)

Also, would you explain what other types of Enum Analytics Economy Transaction Gameplay do? There’s Value, Name and EnumType. I couldn’t find anything about it.

Thank you.

If you are attempting to give a player rewards while they are offline just save their log off time, and when they log back on calculate how long they were gone and give them the correct amount of coins. When they are back on you can use their player value like normal.

With the Enum.AnalyticsEconomyTransactionType only use the name property. What you should be changing is the Gameplay part to one of the other options. This just makes it so you can tell which method the player go the money from. You can read when to use each here;

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.