PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

FireCustomEvent

This function triggers a custom event with a custom event name data.

Limits of events

Each game server is allowed a certain number of standard events API calls based on the number of players present (more players means more events will be needed).
The events that exceed the limit will be dropped and log an error to the developer console.

  • Per minute limit: 120 + numPlayers * 20, all events shared this limit.
  • Cooldown: refresh every 10 seconds

Limits of parameters

Limit the size of parameters. The event that exceeds the limit will be dropped and log an error to the developer console.

Parameters Maximum Number of Characters
customData Variant 500 after serialized
other string types 50

See also

  • AnalyticsService/FirePlayerProgressionEvent, triggers an event used to track player progression through the game
  • AnalyticsService/FireInGameEconomyEvent, triggers an event used to track player actions pertaining to the in-game economy
  • AnalyticsService/FireLogEvent, triggers an event used to track errors and warnings experienced by players

Parameters

Name Type Default Description

The player who triggered the custom event. nil if not player related

User defined category. This should be the name of the event

Optional. User defined data, could be a string, a number or a table

Returns

Return Type Summary

No return


Code Samples


Analytics Event - Custom

The code sample below demonstrates one possible usage for the AnalyticsService/FireCustomEvent|FireCustomEvent() function, which can be used to fire a custom event for the AnalyticsService. In this example, the custom function is used to report that a new server has started, which would allow the developer to track data such as how many servers are started for their game.

local AnalyticsService = game:GetService(“AnalyticsService”)

-- server event, report a new server started
local serverInfo = {Time = os.time(), PlaceId = game.PlaceId}
AnalyticsService:FireCustomEvent(nil, 'ServerStart', serverInfo)

-- player event, report a player chatted event
game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		local customData = {Time = os.time(), Message = msg}
		AnalyticsService:FireCustomEvent(player, 'PlayerChatted', customData)
	end)
end)