Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Your title should be specific! Describe your problem concisely.?

It was just saying Your title should be specific! Describe your problem concisely. And i didn't know what to make the title. Any way, here is the question: can you help me with this code? There are no errors in the code but it output "Bad Id"

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
	    local gametp = math.random(4500000000,3999000000)
	    if gametp >= 0 then
	    local name = (game:GetService("MarketplaceService"):GetProductInfo(gametp).Name)
	    print(name)
	    print(gametp)
	    if string.match(name, "'s Place") then 
        warn("Bad Place")
        local gametp = math.random(4500000000,3999000000)
	    else
		game:GetService("TeleportService"):Teleport(gametp, player)
		end
	    else
        warn("Bad Id")
		end
    end
end
script.Parent.Touched:connect(onTouched)

I dont know what causes it. I tried changing

 local gametp = math.random(4500000000,3999000000)

To

 local gametp = math.random(3999000000,4500000000)

But it then also dont works. Got any help?

Sorry for my bad english.

4 comments

0

Sorry but I dont understand what is the purpose of writing this code. (Like what do you wanna achieve?) Is it a gamepass or some other function you want it to do or achieve?

0

It must teleport you to a random game on roblox, Like place roulette.

0

Im back after 4 months lol. Ok so idk if u still need help but wtv. So the problem could be that the place ID is not valid.

0

Plus if this a thing to tp to places there would only be places you created in the game NOT other games because what ur doing is tping to other games.

2 answers

I think i wknow the answer. At line 5 in the code, There is >= instead of <= So it will always say "Bad Id"

There's a very good chance this is never going to roll a correct ID, first off in order to actually get the place description you must have a valid Place ID, not a Game ID. The ID's for places are not at all sequential on Roblox. It would be far better to just make a big table of allowed Place ID's you can teleport to and choose a random one out of that.

1 comment

0

No, i want it to be completly RANDOM roblox place

This discussion is preserved as it was. New answers, comments, and votes are closed.