Random teleport place

Hello, sorry if the question is obvious but i can’t script at all.
I try to make a script that when you join the game it directly put you in a random place alone, that’s all.

I searched on youtube and devforum and I tried to put several scripts together by modifying them but it does not work

local TeleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer

local s=math.random(1,3)
if s == 1 then
	PlaceId = 10434564161
elseif s == 2 then
	PlaceId = 10434565531
elseif s == 3 then
	PlaceId = 10434566876
end

TeleportService:Teleport(PlaceId, player)

i tried with LocalScript and normal one

1 Like

Try this: Don’t forget to put ur places ids.
Make ServerScript on ServerScriptService and put this in the script:

local TeleportService = game:GetService("TeleportService")
local places = {
	10434564161,
	10434565531,
	10434566876,
}

game.Players.PlayerAdded:Connect(function(player)
	wait(3) -- u can remove it if it's working without wait
	TeleportService:Teleport(places[math.random(1,#places)], player)
end)

okay i tried and it works perfectly, thanks!

1 Like