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

Make a players teleporter to private server ?

Asked by
mist0s 38
5 years ago
Edited 5 years ago

Hello, I am actually doing a game similary to Camping. In my game, there is two place: LobbyServer and GameServer. So, I try to teleport players from the LobbyServer to GameServer. In the LobbyServer, there is a boolvalue called Playing which is false whena player connect. When he touch the part, the value is true and every 60 seconds it teleport players who have their Playing value true. But I really don't know how to teleport players when their Playing value is true to a private server. I use TeleportToPrivateServer and ReserveServer. Yes, I try on the game and not on the roblox studio simulation... So thanks for answer ! :D

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

What you could do is have a for loop in a local script.

When using for loops you can use them to iterate over tables, and game.Players:GetChildren() is counted as a table, so you can do something like this:

01local TeleportService = game:GetService("TeleportService")
02local pv = game.Players:GetChildren()
03local code = TeleportService:ReserveServer(game.[Insert Place ID])
04 
05 
06while true do
07    wait(60)
08    for i = 1, #pv do
09        local value = pv[i]
10        if value.[Insert location of Playing value].Value == true then
11        TeleportService:TeleportToPrivateServer(game.[Insert Place ID],code,value)
12    end
13end

Value is the parameter for what player it's currently looking at.

Then put this inside the script in the part you want people to touch:

01local function debounce(func) --Makes touch events not fire more then once per person
02    local isRunning = false
03    return function(...)
04        if not isRunning then
05            isRunning = true
06 
07            func(...)
08 
09            isRunning = false
10        end
11    end
12end
13 
14script.Parent.Touched:Connect(debounce(function(part)
15    local Humanoid = part.Parent:FindFirstChild("Humanoid")
16    if Humanoid then
17        local player = game.Players:GetPlayerFromCharacter(part.Parent)
18        player.[Insert location of player value].Value = true
19    end
20end))

Then when the player teleport script runs in 60 seconds it will teleport anyone that has their playing value set to true.

Let me know if you have any questions.

0
Really thanks for an answer so fast. For the script I try that on a script and local script: local TeleportService = game:GetService("TeleportService") local pv = game.Players:GetChildren() local code = TeleportService:ReserveServer(2675486660) while true do wait(60) for i = 1, #pv do local value = pv[i] if value.FindFirstChild("Settings").Playing.Value == true then mist0s 38 — 5y
0
TeleportService:TeleportToPrivateServer(3154696827,code,value) end end end (the end of the comment) mist0s 38 — 5y
0
But it doesn't work, why ?? mist0s 38 — 5y
View all comments (2 more)
0
Did you add the regular script inside the part that you want people to touch? Babyseal1015 56 — 5y
0
Also in the local script, it will need to be in starter player scripts, and on the while true do statement it needs an extra end I forgot to add that. And then ReserveServer() and TeleportToServer() both need to have the Id of the place that you want to teleport the players to. Babyseal1015 56 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

To players teleport between places create a part that you want to player touch it and get teleported and insert a script

1script.Parent.Touched:Connect(function(player)
2    if player.Parent:FindFirstChild("HumanoidRootPart") then
3    local service = game:GetService("TeleportService");
4    local place = 20279777; --Put the map id that you want to players get teleported
5    local plr = game.Players:GetPlayerFromCharacter(player.Parent)
6     service:Teleport(place,plr);
7         end
8end)

Answer this question