I’ve been trying to use the new Rewardable Ads feature. I’ve ran into a couple issues which I’ve fixed except one where Roblox returns “InternalError” as an AdAvailability Enum. I’ve read on the forum post that it would be related to products but I did not find any. My snippets are down below.
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local AdService = game:GetService("AdService")
local RewardedAdEvent = ReplicatedStorage:WaitForChild("RewardedAdEvent")
RewardedAdEvent.OnServerEvent:Connect(function(player)
warn(game.PlaceVersion)
local isSuccess, result = pcall(function()
local reward = AdService:CreateAdRewardFromDevProductId(3427867505)
return AdService:ShowRewardedVideoAdAsync(player, reward)
end)
warn(isSuccess, result)
RewardedAdEvent:FireClient(player, isSuccess, result)
end)
local Workspace = game:GetService("Workspace")
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == 3427867505 then
ReplicatedStorage.FetchRev:FireClient(player)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Services
local AdService = game:GetService("AdService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- StarterGui ⟩ ScreenGui ⟩ ShopFrame ⟩ RewardedAdButton
local RewardedAdButton = script.Parent
-- Event to communicate between clients & server
local RewardedAdEvent = ReplicatedStorage:WaitForChild("RewardedAdEvent")
local INELIGIBLE_RESULTS = {
Enum.AdAvailabilityResult.PlayerIneligible,
Enum.AdAvailabilityResult.DeviceIneligible,
Enum.AdAvailabilityResult.PublisherIneligible,
Enum.AdAvailabilityResult.ExperienceIneligible,
}
local function isIneligible(result: Enum.AdAvailabilityResult)
for _, inEligibleResult in ipairs(INELIGIBLE_RESULTS) do
if result == inEligibleResult then
return true
end
end
return false
end
function checkForAds()
local isSuccess, result = pcall(function()
return AdService:GetAdAvailabilityNowAsync(Enum.AdFormat.RewardedVideo)
end)
if isSuccess and result.AdAvailabilityResult == Enum.AdAvailabilityResult.IsAvailable then
warn(isSuccess, result.AdAvailablityResult)
RewardedAdButton.Visible = true
return
end
if isIneligible(result.AdAvailabilityResult) then
return
end
end
RewardedAdEvent.OnClientEvent:Connect(function(isSuccess : boolean, result : Enum.ShowAdResult)
if result == Enum.ShowAdResult.ShowCompleted then
checkForAds()
end
end)
RewardedAdButton.MouseButton1Click:Connect(function()
--RewardedAdButton.Visible = false
task.delay(0.3, function()
warn("a")
RewardedAdEvent:FireServer()
end)
end)
Know that I’ve only got one ProcessReceipt