hi, I was working at an Ad Sistem, but there is a problem with the part of showing the ad. If I want to put it manually it works, but when I want a script to put it this error appears:
the id is same and if u put it manually or with a script:
function AdService:AddAd(price,id,timeStamp,Time)
local formatData = {price,id,timeStamp,Time}
local receivedData = AdStore.VideoSaving:GetAsync('VideoSavingKey3')
if receivedData ~= nil then
receivedData = game.HttpService:JSONDecode(receivedData)
receivedData[tonumber((#receivedData) + 1)] = formatData
receivedData = game.HttpService:JSONEncode(receivedData)
AdStore.VideoSaving:SetAsync('VideoSavingKey3',receivedData)
else
receivedData = {}
receivedData[tonumber((#receivedData) + 1)] = formatData
receivedData = game.HttpService:JSONEncode(receivedData)
AdStore.VideoSaving:SetAsync('VideoSavingKey3',receivedData)
end
end
the Showing function:
function ShowAd(Holder)
local Ad = Holder:WaitForChild('Ad')
if #ServiceFunctions:GetVideos() >= 1 then
if Ad:IsA('Decal') or Ad:IsA("Texture") then
Ad.Texture = tostring(GetRandomAd('Decal'))
elseif Ad:IsA('ImageButton') or Ad:IsA('ImageLabel') then
Ad.Image = tostring(GetRandomAd('Gui'))
end
end
end