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)
local gametp = math.random(3999000000,4500000000)
But it then also dont works. Got any help?
Sorry for my bad english.
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.