AdService

Show Deprecated
Not Creatable
Service

A service for displaying mobile video ads as a form of monetization. Use it to implement rewarded video ads in your experience.

Summary

Methods

Properties

Methods

CreateAdRewardFromDevProductId

AdReward

Creates a reward to give users who watch an entire video ad.

Parameters

devProductId: number

The ID of the developer product you want to grant as a reward.

Default Value: ""

Returns

AdReward

ShowVideoAd

()
Deprecated

Show mobile video advertisements.


Returns

()

UnregisterAdOpportunity

()

Parameters

instance: Instance

Returns

()

GetAdAvailabilityNowAsync

Variant
Yields

Checks if a video ad is available to be played to the current user inside the experience.

Parameters

adFormat: Enum.AdFormat

The format of the requested ad. For example, RewardedOnDemandVideo.


Returns

Variant

Code Samples


local adAvailabilityResult = AdService:GetAdAvailabilityNow(Enum.AdAdFormat.RewardedOnDemandVideo)

RegisterAdOpportunityAsync

()
Yields

Parameters

instance: Instance
placementId: number

Returns

()

ShowRewardedVideoAdAsync

Yields

Plays the video ad to the current user inside the experience.

Parameters

player: Player

The Player object for whom you are fetching the ad for.

reward: AdReward

The reward object for the reward you want to grant the user who watches an ad to completion.

placementId: number

The ID of the placement of the rewarded video ad inside the experience. Allows for reporting on the performance of individual ad placements.


Returns

Code Samples


local reward = AdService:CreateAdRewardFromDevProductId(100)
local result = AdService:ShowRewardedVideoAdAsync(player, reward)

Events

VideoAdClosed

Deprecated

Fires when an AdService video closes.

Parameters

adShown: boolean