Efficient Way to Check if a Number is a Game in a Repeat Loop (Bad Request, HTTP 400)

close

problem fixed, new problem not related to post anymore

Wrap the line where you get the product into a pcall, and from the pcall, you can handle errors.

but it’s in a pcall
if pcall(yesss) then

		script.Parent.tele.SurfaceGui.TextLabel.Text = "ERROR, Finding New Timeline..."
		
		warn("Returned")
		
		yesss()
		
	end

Help how do i fix it

This text will be blurred

You didnt add an else statement to the pcall.

I think you can avoid sending too much requests.
I got the same error trying to get product info
Try changing wait(.01) to 5 seconds

function sendRequest(placeId)
	local success,info
	success,info = pcall(game:GetService('MarketplaceService'):GetProductInfo(placeId))
	return success,info
end


function onClickEvent(hit)

	script.Parent.tele.SurfaceGui.TextLabel.Text = "Finding Timeline"
	script.Parent.dothething.ClickDetector.MaxActivationDistance = 0
	script.Parent.BTI.ClickDetector.MaxActivationDistance = 0
	script.Parent.clocks.AngularVelocity.Enabled = true
	script.Parent.effect.Transparency = 0
	script.Parent.clocks.SFX:Play()
	script.Parent.effectnochoice.ParticleEmitter.Enabled = true
	script.Parent.effectnochoice.szb:Play()
	hit.leaderstats.Clicks.Value = hit.leaderstats.Clicks.Value + 1
	script.Parent.curent.SurfaceGui.TextLabel.TextColor = BrickColor.Black()
	tweenfun2()

	
	local placeId
	local success,info
	repeat 
		placeId = math.random(1,100000)
		script.Parent.curent.SurfaceGui.TextLabel.Text = "Timeline: "..placeId
		success,info = sendRequest(placeId)
	until success == true and info.AssetTypeId == 9
	
	script.Parent.clocks.Open.Playing = true
	script.Parent.clocks.Open.TimePosition = 0
	script.Parent.curentgamename.SurfaceGui.TextLabel.Text = info.Name
	script.Parent.curentgamename2.SurfaceGui.TextLabel.Text = info.Name

	script.Parent.curent.SurfaceGui.TextLabel.TextColor = BrickColor.Green()
	script.Parent.tele.SurfaceGui.TextLabel.Text = "Teleporting in 2 seconds"
	wait(2)
	script.Parent.tele.SurfaceGui.TextLabel.Text = "Teleporting..."
	TeleportService:Teleport(placeId, hit)
	wait(3)
	script.Parent.tele.SurfaceGui.TextLabel.Text = "Try again!"
	wait(1)
	script.Parent.tele.SurfaceGui.TextLabel.Text = "Click To activate"
	script.Parent.clocks.SFX:Stop()
	script.Parent.effectnochoice.ParticleEmitter.Enabled = false
	script.Parent.effect.Transparency = 1
	script.Parent.BTI.ClickDetector.MaxActivationDistance = 15
	script.Parent.dothething.ClickDetector.MaxActivationDistance = 15
	script.Parent.clocks.AngularVelocity.Enabled = false
	script.Parent.clocks.Velocity = Vector3.new(0,0,0)
end
script.Parent.dothething.ClickDetector.MouseClick:Connect(onClickEvent)

I tried it but for some reason it is stuck on the finding timeline section