Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago
Edited 4 years ago

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.

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? RebornedSnoop 175 — 4y
0
It must teleport you to a random game on roblox, Like place roulette. hasanchik 49 — 4y
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. RebornedSnoop 175 — 4y
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. RebornedSnoop 175 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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

Ad
Log in to vote
0
Answered by 4 years ago

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.

0
No, i want it to be completly RANDOM roblox place hasanchik 49 — 4y

Answer this question