Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to use the ShowAd() function?

Asked by 8 years ago

So I was reading on the wiki, and I found the ShowAd() function. How would someone like me use this on a game I have?

Here the wiki post.

1 answer

Log in to vote
1
Answered by 8 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

When to show an ad

Round or level based games: Showing the ad automatically while players are waiting for the next round to load is a great way to not interrupt gameplay and provide a huge amount of ad impressions since every player will automatically see the ad each round.

Note: This only works in mobile as of now.

Note: You can only show 5 ads for each player every hour.

Code:

local adservice = game:GetService("AdService")  -- Define AdService
adservice:ShowVideoAd () -- Show Ad 

adservice .VideoAdClosed:connect(function(shown) -- Run when ad finishes where shown equals true or false depending if the ad showed or an error occurred
    if shown then -- If statement to check what happened
        print("Finished showing video ad.") 
    else
        print("The ad didn't get shown")
    end
end)
Ad

Answer this question