So, I know that in studio you cant teleport and it gives an error. So I went in game, and tested it. It gave the error argument 3 missing or nil, on line 24. How do I get the players, if they have the bool value, to teleport to the place? I dont want everyone to teleport there, just the players with the bool value. How would I do that? If I could get the players names, I would just teleport them. But they would have to be in a variable. Half the code, is just for difficulty, the bottom is the teleporting part.
local remote = game.ReplicatedStorage.StartEvent
remote.OnServerEvent:Connect(function()
for i, v in pairs(game.Players:GetPlayers()) do
local bool = v:FindFirstChildOfClass("BoolValue")
local frame = v.PlayerGui.ActiveLobbys.Frame.Frame.Frame
local player2 = frame.PlayerName.Text
local gameplaceid = 3313994275
if bool then
print("Start")
if bool.Name == player2 then
if frame.Difficulty.Text == "Medium" then
gameplaceid = 3313994275
elseif frame.Difficulty.Text == "Hard" then
gameplaceid = 3313994275
end
end
local TeleportService = game:GetService("TeleportService")
local Reserve = TeleportService:ReserveServer(gameplaceid)
--local Players = game.Players:GetPlayers() --// Returns an array of all Players
TeleportService:TeleportToPrivateServer(gameplaceid, Reserve)--, Players)
--end
end
end
end)
