What is wrong with my random game teleporter?
I am trying to make a random game teleporter, (much of the code is from an Eppobot video, but I modified it for my needs) and I ran into the issue initially when I used math.random(100000000, 999999999) for the place ID, but then I realised it didn't reset or change. (It did work) the ID that it generated stayed the same on the server until it closed, which is damaging because it tries to teleport to a restricted place repetitively sometimes. So I made an infinite loop with a variable that was given a new math.random every second, and then I made the place ID equal to the variable, but now it doesn't teleport at all. here is my code:
02 | randomgame = math.random( 100000000 , 999999999 ) |
06 | local TeleportService = game:GetService( "TeleportService" ) |
07 | local Place = randomgame |
08 | script.Parent.Touched:connect( function (hit) |
09 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
11 | TeleportService:Teleport(Place, player) |
Thank you for taking the time to look at this.
Sincerely,
ACDCMASTA