# AdService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/AdService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/AdService

The service responsible for in-experience advertising.

## Methods

### CreateAdRewardFromDevProductId

```luau
AdService:CreateAdRewardFromDevProductId(devProductId: number): AdReward
```

- Tags: Capabilities: Monetization

Creates an [`AdReward`](https://rapi.sleaze.dev/index/types/AdReward.md) to give users who watch a video ad.

Parameters:

- `devProductId`: The ID of the developer product you want to grant as a reward.

Returns: An [`AdReward`](https://rapi.sleaze.dev/index/types/AdReward.md) configured as a developer product reward for the specified product.

### GetAdAvailabilityNowAsync

```luau
AdService:GetAdAvailabilityNowAsync(adFormat: Enum.AdFormat): { [string]: any }
```

- Tags: Yields, Capabilities: Monetization

Checks if an ad with the specified format is available to be shown to the `LocalPlayer`.

Parameters:

- `adFormat`: The format of the requested ad. For example, `AdFormat.RewardedVideo`.

Returns: A dictionary that looks like `{ AdAvailabilityResult: Enum.AdAvailabilityResult }`.

### GetAdAvailabilityNowForUniverseAsync

```luau
AdService:GetAdAvailabilityNowForUniverseAsync(adFormat: Enum.AdFormat, universeId: number, isUniversalAppDM: boolean): { [string]: any }
```

- Tags: Yields, Roblox script security, Capabilities: Monetization

### GetAdTeleportInfo

```luau
AdService:GetAdTeleportInfo(): ...any
```

- Tags: Roblox script security, Capabilities: Monetization

### GetCampaignEligibilityAsync

```luau
AdService:GetCampaignEligibilityAsync(campaignId: string, player: Player? = nil): { [string]: any }
```

- Tags: Yields, Capabilities: Monetization

Checks a [`Player`](https://rapi.sleaze.dev/classes/Player.md)'s eligibility to be shown an [ad integration](https://create.roblox.com/docs/production/promotion/ad-integrations) campaign.

Parameters:

- `campaignId`: The ID of the campaign that you want to check a [`Player`](https://rapi.sleaze.dev/classes/Player.md)'s eligibility for.
- `player`: The [`Player`](https://rapi.sleaze.dev/classes/Player.md) you want to check eligibility for. If omitted, it will default to the `LocalPlayer`. On the server, `player` argument is required.

Returns: A dictionary that looks like `{ IsEligible: boolean }`.

### GetReportAdInfo

```luau
AdService:GetReportAdInfo(): { any }
```

- Tags: Roblox script security, Capabilities: Monetization

### GetUniversalAppAdsEligibility

```luau
AdService:GetUniversalAppAdsEligibility(): { [string]: any }
```

- Tags: Roblox script security, Capabilities: Monetization

### HandleWhyThisAdClicked

```luau
AdService:HandleWhyThisAdClicked(advertiserName: string, payerName: string)
```

- Tags: Roblox script security, Capabilities: Monetization

### HideEudsaDisclosure

```luau
AdService:HideEudsaDisclosure()
```

- Tags: Roblox script security, Capabilities: Monetization

### IsAdLoaded

```luau
AdService:IsAdLoaded(adFormat: Enum.AdFormat): boolean
```

- Tags: Roblox script security, Capabilities: Monetization

### OnDemandVideoCompleteFromUI

```luau
AdService:OnDemandVideoCompleteFromUI(result: Enum.ShowAdResult, encryptedAdTrackingData: string, encryptionMetadata: string, rewardDetails: string)
```

- Tags: Roblox script security, Capabilities: Monetization

### RegisterAdOpportunityAsync

```luau
AdService:RegisterAdOpportunityAsync(instance: Instance, placementId: number?)
```

- Tags: Yields, Capabilities: Monetization

Tracks how many times a user had the chance to watch a video ad and the rate at which they actually watched the ad.

Parameters:

- `instance`: The [`GuiButton`](https://rapi.sleaze.dev/classes/GuiButton.md) to track as a rewarded video ad opportunity. Must be a descendant of a [`ScreenGui`](https://rapi.sleaze.dev/classes/ScreenGui.md).
- `placementId`: The ID of the placement of the rewarded video ad inside the experience. Allows for reporting on the performance of individual ad placements.

### RegisterDisclosureButton

```luau
AdService:RegisterDisclosureButton(disclosureButton: GuiButton, adIntegrationPlacementId: string)
```

- Tags: Capabilities: Monetization

Registers an ad disclosure button for an [ad integration](https://create.roblox.com/docs/production/promotion/ad-integrations).

Parameters:

- `disclosureButton`: The [`GuiButton`](https://rapi.sleaze.dev/classes/GuiButton.md) you want to mark as an ad integration disclosure. The [`GuiButton`](https://rapi.sleaze.dev/classes/GuiButton.md) must follow labeling guidelines outlined [here](https://create.roblox.com/docs/production/promotion/ad-integrations#labeling-and-disclosure).
- `adIntegrationPlacementId`: The ID of the placement that this disclosure is attached to.

### RegisterImpressionSource

```luau
AdService:RegisterImpressionSource(instance: Instance, adIntegrationPlacementId: string)
```

- Tags: Capabilities: Monetization

### ReturnToPublisherExperience

```luau
AdService:ReturnToPublisherExperience(adTeleportMethod: Enum.AdTeleportMethod)
```

- Tags: Roblox script security, Capabilities: Monetization

### SetAdGuiInteractivityHandlerInitialized

```luau
AdService:SetAdGuiInteractivityHandlerInitialized()
```

- Tags: Roblox script security, Capabilities: Monetization

### ShowRewardedVideoAdAsync

```luau
AdService:ShowRewardedVideoAdAsync(player: Player, reward: AdReward, placementId: number?): Enum.ShowAdResult
```

- Tags: Yields, Capabilities: Monetization + UI

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

Parameters:

- `player`: The [`Player`](https://rapi.sleaze.dev/classes/Player.md) to trigger a rewarded video ad play for.
- `reward`: The [`AdReward`](https://rapi.sleaze.dev/index/types/AdReward.md) to grant the user after they view the ad.
- `placementId`: The ID of the placement of the rewarded video ad inside the experience. Allows for reporting on the performance of individual ad placements.

Returns: The `ShowAdResult` of the client's ad presentation. You should not use this result to grant the reward. Instead, you should grant the reward from your `ProcessReceipt` implementation. For [developer products](https://create.roblox.com/docs/production/monetization/developer-products) earned through rewarded video ads, the `ProductPurchaseChannel` will be `ProductPurchaseChannel.AdReward`.

### ShowRewardedVideoAdAtClientAsync

```luau
AdService:ShowRewardedVideoAdAtClientAsync(universeId: number): Enum.ShowAdResult
```

- Tags: Yields, Roblox script security, Capabilities: Monetization

### SubmitAdNotification

```luau
AdService:SubmitAdNotification(universeId: number, isShowAdSuccessful: boolean, earnedReward: boolean, rewardProductName: string, rewardProductImageAssetId: number)
```

- Tags: Roblox script security, Capabilities: Monetization

### UnregisterAdOpportunity

```luau
AdService:UnregisterAdOpportunity(instance: Instance)
```

- Tags: Capabilities: Monetization

Stops tracking an instance that was previously registered with [`RegisterAdOpportunityAsync`](https://rapi.sleaze.dev/classes/AdService.md).

Parameters:

- `instance`: The instance to stop tracking. This should be an instance that you previously passed to [`RegisterAdOpportunityAsync()`](https://rapi.sleaze.dev/classes/AdService.md).

### ShowVideoAd

```luau
AdService:ShowVideoAd()
```

- Tags: Deprecated, Capabilities: Monetization

**Deprecated:** [`ShowVideoAd`](https://rapi.sleaze.dev/classes/AdService.md) has been decommissioned and is no longer operational.

Show mobile video advertisements.

## Events

### AdTeleportEnded

```luau
AdService.AdTeleportEnded: RBXScriptSignal<()>
```

- Tags: Roblox script security, Capabilities: Monetization

### AdTeleportInitiated

```luau
AdService.AdTeleportInitiated: RBXScriptSignal<()>
```

- Tags: Roblox script security, Capabilities: Monetization

### CampaignEligibilityResponseFailureSignalFromClient

```luau
AdService.CampaignEligibilityResponseFailureSignalFromClient: RBXScriptSignal<(campaignId: string, error: string)>
```

- Tags: Hidden, Roblox engine security, Capabilities: Monetization

### CampaignEligibilityResponseSuccessSignalFromClient

```luau
AdService.CampaignEligibilityResponseSuccessSignalFromClient: RBXScriptSignal<(campaignId: string, response: { [string]: any })>
```

- Tags: Hidden, Roblox engine security, Capabilities: Monetization

### GetCampaignEligibilitySignalFromServer

```luau
AdService.GetCampaignEligibilitySignalFromServer: RBXScriptSignal<(campaignId: string)>
```

- Tags: Hidden, Roblox engine security, Capabilities: Monetization

### ReportImpressionSignal

```luau
AdService.ReportImpressionSignal: RBXScriptSignal<(ad_instance_name: string, encrypted_ad_tracking_data: string, encryption_metadata: string)>
```

- Tags: Hidden, Roblox engine security, Capabilities: Monetization

### ReportTeleportSignal

```luau
AdService.ReportTeleportSignal: RBXScriptSignal<(ad_instance_name: string, encrypted_ad_tracking_data: string, encryption_metadata: string, teleport_type: string, teleport_source_universe_id: number, teleport_source_place_id: number, teleport_dest_place_id: number)>
```

- Tags: Hidden, Roblox engine security, Capabilities: Monetization

### RewardedVideoAdEnded

```luau
AdService.RewardedVideoAdEnded: RBXScriptSignal<()>
```

- Tags: Roblox script security, Capabilities: Monetization

### RewardedVideoAdStarted

```luau
AdService.RewardedVideoAdStarted: RBXScriptSignal<()>
```

- Tags: Roblox script security, Capabilities: Monetization

### ServeAdResponseSignal

```luau
AdService.ServeAdResponseSignal: RBXScriptSignal<(uuid: string, response: string, isError: boolean)>
```

- Tags: Hidden, Roblox engine security, Capabilities: Monetization

### ServeAdSignal

```luau
AdService.ServeAdSignal: RBXScriptSignal<(uuid: string, request: string)>
```

- Tags: Hidden, Roblox engine security, Capabilities: Monetization

### ShowDynamicEudsaDisclosure

```luau
AdService.ShowDynamicEudsaDisclosure: RBXScriptSignal<(advertiserName: string, payerName: string)>
```

- Tags: Roblox script security, Capabilities: Monetization

### ShowReportAdPopup

```luau
AdService.ShowReportAdPopup: RBXScriptSignal<(adInfo: { [string]: any })>
```

- Tags: Roblox script security, Capabilities: Monetization

### adGuiRegisterUI

```luau
AdService.adGuiRegisterUI: RBXScriptSignal<(adGui: Instance)>
```

- Tags: Roblox script security, Capabilities: Monetization

### rewardedVideoAdPlayServerToClient

```luau
AdService.rewardedVideoAdPlayServerToClient: RBXScriptSignal<(rewardDetails: string)>
```

- Tags: Hidden, Roblox engine security, Capabilities: Monetization

### rewardedVideoAdPlayServerToClientWithPlacement

```luau
AdService.rewardedVideoAdPlayServerToClientWithPlacement: RBXScriptSignal<(rewardDetails: string, placementId: number)>
```

- Tags: Hidden, Roblox engine security, Capabilities: Monetization

### rewardedVideoAdResultClientToServer

```luau
AdService.rewardedVideoAdResultClientToServer: RBXScriptSignal<(result: Enum.ShowAdResult, encryptedAdTrackingData: string, encryptionMetadata: string)>
```

- Tags: Hidden, Roblox engine security, Capabilities: Monetization

### VideoAdClosed

```luau
AdService.VideoAdClosed: RBXScriptSignal<(adShown: boolean)>
```

- Tags: Deprecated, Capabilities: Monetization

**Deprecated:** [`VideoAdClosed`](https://rapi.sleaze.dev/classes/AdService.md) has been decommissioned and is no longer operational.

Fires when an [`AdService`](https://rapi.sleaze.dev/classes/AdService.md) video closes.

## Callbacks

### OnImmersiveBrandedAdDisclosureButtonActivated

```luau
AdService.OnImmersiveBrandedAdDisclosureButtonActivated: (data: { [string]: any }) -> ()
```

- Tags: No yield, Roblox script security, Capabilities: Monetization

### onDemandVideoPlayInUI

```luau
AdService.onDemandVideoPlayInUI: (data: { [string]: any }) -> VideoFrame
```

- Tags: Roblox script security, Capabilities: Monetization

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
