Why is "AdGui.OnAdEvent" is not getting triggered, even if I watched an immersive ad in my game?

Code:

local AdModel = game.Workspace:FindFirstChild("Image Ad Unit 2")
if AdModel and AdModel:FindFirstChild("ADpart") then
	AdGui = AdModel.ADpart:FindFirstChild("AdGui")
		if AdGui then
		AdGui = AdModel.ADpart.AdGui
		print("Ad")
		AdGui.OnAdEvent = function(eventData)
			local AdEventType = eventData.AdEventType
			local PlayerId = eventData.PlayerId
			if AdEventType == Enum.AdEventType.RewardedAdLoaded then
				print("Loaded ad")
				showRewardPrompt(PlayerId)
				return true
			elseif AdEventType == Enum.AdEventType.RewardedAdGrant then
				print("Granted ad")
				grantReward(PlayerId)
				hideRewardPrompt(PlayerId)
				return true
			elseif AdEventType == Enum.AdEventType.RewardedAdUnloaded then
				print("Unloaded ad")
				hideRewardPrompt(PlayerId)
				return true
			end
			return false
		end
	end
end

You gotta connect OnAdEvent to a function

AdGui.OnAdEvent:Connect(function(eventData)
	local AdEventType = eventData.AdEventType
	local PlayerId = eventData.PlayerId
	if AdEventType == Enum.AdEventType.RewardedAdLoaded then
		print("Loaded ad")
		showRewardPrompt(PlayerId)
		return true
	elseif AdEventType == Enum.AdEventType.RewardedAdGrant then
		print("Granted ad")
		grantReward(PlayerId)
		hideRewardPrompt(PlayerId)
		return true
	elseif AdEventType == Enum.AdEventType.RewardedAdUnloaded then
		print("Unloaded ad")
		hideRewardPrompt(PlayerId)
		return true
	end
	return false
end
1 Like

I got this error from that code, btw this is for immersive ads (not for a remote event):
OnAdEvent is a callback member of AdGui; you can only set the callback value, get is not available

Sry my bad. You should’nt connect it since its a callback. Does it print ‘Ad’? If it does then the ad gui is probably not even an ad gui. Go verify if it is.

Sorry if I can’t solve this, never did ads b4