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

How to make Video Ads?

Asked by
IcyEvil 260 Moderation Voter
10 years ago

I would like to know how to make the ad Actually Come up, The blog said It is now possible to do so Make Video ads in game (for Mobile but I think I can make it for everyone) and I need to know What I need to do in order for it to play an ad, and possibly how to create one.

I took this from the wiki, but it had different parts.

game:GetService("AdService"):ShowVideoAd()

game:GetService("AdService").VideoAdClosed:connect(function()
    print("Finished showing video ad.") 
end)

local remoteEvent = Instance.new("RemoteEvent")
remoteEvent.Name = "ForceFieldEvent"
remoteEvent.Parent = game.ReplicatedStorage


remoteEvent.OnServerEvent:connect(function(player, turnOnForceField)

    local character = player.Character
    if character then
        if turnOnForceField then

            local forceField = Instance.new("ForceField")
            forceField.Name = "AdForceField"
            forceField.Parent = character
        else

            local forceField = character:FindFirstChild("AdForceField")
            if forceField then
                forceField:Destroy()
            end
        end
    end
end)

game:GetService("AdService").VideoAdClosed:connect(function()
    game.ReplicatedStorage.ForceFieldEvent:FireServer(false)
end)


local function playAd()
    game:GetService("AdService"):ShowVideoAd()
    game.ReplicatedStorage.ForceFieldEvent:FireServer(true)
end


script.Parent.MouseButton1Click:connect(playAd)

1 answer

Log in to vote
-2
Answered by 10 years ago

Put this in a LocalScript which will be placed in a TextButton. Once done, you may do whatever else you'd like.

Game:GetService("AdService").VideoAdClosed:connect(function() Game:GetService("UserInputService").ModalEnabled = false script.Parent.Text = "Ad was closed, this text will reset in 5 secs" wait(5) script.Parent.Text = "Tap Here to Play Ad" end) script.Parent.MouseButton1Click:connect(function() Game:GetService("UserInputService").ModalEnabled = true Game:GetService("AdService"):ShowVideoAd() end)

Ad

Answer this question