Random Number Generator/Place ID teleport

If this is correct how do I add a wait function for a random time interval for it to execute such as 1 min to 5 min

Do you want to add an interval to when it generates the number or when it validates it?

I want an interval for when to generate the ID

Well If I’m correct there wouldn’t be a difference for whichever, so just adding a wait() before the script should work properly

1 Like

so if the id thing produces a valid id will it teleport the user to a server?

It just validates the ID, I’ll tell you how to make it join the random game though.

Alright that sounds good. I’ll be here waiting.

I also need to figure out how to repeat the script incase the id is not valid

while true do
	wait(120)
	local MPS = game:GetService("MarketplaceService")

	local ID = math.random(1000000, 99999999)
	print(ID)
	
	local PlaceCheck

	local success, whoops = pcall(function()

		PlaceCheck = MPS:GetProductInfo(ID)

	end)

	if success and PlaceCheck and PlaceCheck.AssetTypeId == 9 then
		game:GetService('TeleportService'):Teleport(ID)
		print("The player has entered a valid place ID")

	else

		warn("The player has entered a incorrect valid place ID: ", whoops)

	end
end

Try this script

I am in game right now and i am not teleporting to any game but I do not know if the games are invalid or locked.

Ima set the wait to 1 or 0.1 to see if its the script.

Ok so the script is at 0.5 and I published and now I’m testing it and I am not teleporting anywhere.

Do I need to enable something in studio?

image
Hey, sorry I am going to be busy for some time, but did you enable this?

I just did. I’m going to test it.

Inside of the studio thing it displays
image
and in game without the third party teleports on it hasn’t teleported me.

Well the id’s are invalid but idk about the invalid player to teleport

If you are testing it in studio, then test it in-game

I have been testing it in game and so far I haven’t been teleported to any game.