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

How to use Video Ads?

Asked by 8 years ago

I've been attempting to implement video ads into my game, and I can't quite get the VideoAdClosed event to function properly. The idea is, someone joins the game and is eligible to watch an ad. They can click a GUI, and watch an advertisement to earn 2 in-game currency. The problem is this; After someone viewed an ad, the script claims they didn't watch it. When they didn't watch it(they'd already watched 5 ads in that hour,) it also claimed they didn't see the ad. I need the script to differentiate between when someone actually watched the ad, and when they didn't. Here's the code:

plr = game.Players.LocalPlayer
game:GetService("AdService").VideoAdClosed:connect(function(shown)
    if shown then
        plr.Tuudbucks.Value = plr.Tuudbucks.Value + 2
        script.Parent.Parent.Parent.Thanks.Visible = true
    else
        local thank = script.Parent.Parent.Parent.Thanks
        thank.Visible = true
        local cur = thank.TextLabel
        local te = cur.Text
        cur.Text = "Ad not shown. You may only watch 5 ads per hour."
        wait(3)
        cur.Text = te
        end
end)
 script.Parent.MouseButton1Click:connect(function()
    if plr:FindFirstChild("Alive").Value == false then
    script.Parent.Parent.Visible = false
    game:GetService("AdService"):ShowVideoAd()
    else
        local tx = script.Parent.Parent.TextLabel.Text
        script.Parent.Parent.TextLabel.Text = "You cannot watch an ad while you're in a game!"
        script.Parent.Parent.TextLabel.Text = tx
    end
end)
0
You do know that video ads only show on mobile devices, right? yumtaste 476 — 8y
0
Yes, I am aware of this. To test this I've been using my NBC mobile device. Furthermore, there is a separate script allowing only NBC mobile device users to see the GUI. Toadboyblue 67 — 8y
0
So, the ad shows, and the player doesn't get their money? yumtaste 476 — 8y
0
The ad shows, and it runs lines 7-14. Toadboyblue 67 — 8y

Answer this question