Code doesnt update for some reason

Hello! When the player first joins the game it shows how many ugc copies there are. But for some reason it never updates unless they rejoin. Does anyone know why? BTW its a localscript



game:GetService("RunService").RenderStepped:Connect(function()
	local MarketplaceService = game:GetService("MarketplaceService")
	local assetId = 15406442659
	local productInfo = MarketplaceService:GetProductInfo(assetId, Enum.InfoType.Asset)
	for k, v in pairs (productInfo) do
		if k == "Remaining" then
			script.Parent.amt.Text = v.."/100"
		end
		print(k)
		print(v)
	end
end)
3 Likes

pls someone help im stumped! I dont know what to do and im releasing a ugc soon

1 Like

What are you trying to achieve?

It looks like you’re just checking for one item in the script you provided. And why does this need to be updated every frame? And what exactly isn’t working?

So yes im checking for one item. The problem is it never updates(unless you rejoin)

See if this works. (gonna not use RunService :grimacing:)

local marketplaceService = game:GetService("MarketplaceService")

local root = script.Parent
local amount = root:WaitForChild("amt")

local assetId = 15406442659

local function ugcChecker()
    while true do
        local success, response = pcall(
            marketplaceService.GetProductInfo,
            marketplaceService,
            assetId,
            Enum.InfoType.Asset
        )
        if success then
            if response.Remaining then
                amount.Text = response.Remaining .. "/100"
            end
        else
            warn(response)
        end

        task.wait(10) -- Interval
    end
end
task.defer(ugcChecker)

Edit 1: Fixed some typos. Try again if it didn’t work.

1 Like

Im so sorry for the late response(I didnt check my notifications)! Yes it works fine im just not sure if it updates since the ugc is out of stock. Lets just pray that it works! :pray: Thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.