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
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.