So I’m trying to make a lobby like the one in Fortnite, but there is a problem. I can’t seem to figure out how to teleport the players. I tried just teleporting the players but it never teleported to the other pads or the players were just on one pad. I also tried cloning but it keeps giving me this error:
Here’s the code:
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Captures, false)
local plrs = game.Players
local plr = plrs.LocalPlayer
repeat wait() until plr.Character
local cam = workspace.CurrentCamera
local midcam = workspace.Lobby.Cam
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = midcam.CFrame
local char = plr.Character or plr.CharacterAdded:Wait()
local plrCount = game.ReplicatedStorage.PlayersInTotal
local Teleport = {
one = workspace.Lobby.Pads.MIddlePad.Location,
two = workspace.Lobby.Pads.LeftPad.Location,
three = workspace.Lobby.Pads.RightPad.Location
}
local usedright = false
local usedleft = false
local rightplr = nil
local leftplr = nil
local function anchor(char)
if not char then return end
for _, v in pairs(char:GetDescendants()) do
if v:IsA("Part") then
v.Anchored = true
elseif v:IsA("MeshPart") then
v.Anchored = true
end
end
end
local function unanchor(char)
if not char then return end
for _, v in pairs(char:GetDescendants()) do
if v:IsA("Part") then
v.Anchored = false
elseif v:IsA("MeshPart") then
v.Anchored = false
end
end
end
local function tp(Player,number)
local Character = Player.Character or Player.CharacterAdded:Wait()
if not Character then return end
local c = Character:Clone()
c.Name = Character.Name.."Clone" --The error is right here!
c.Parent = workspace
anchor(c)
wait(2)
c:PivotTo(number.CFrame)
unanchor(c)
end
for _, v in pairs(plrs:GetPlayers()) do
local vchar = v.Character or v.CharacterAdded:Wait()
if plrCount.Value == 1 then
tp(plr, Teleport.one)
if usedleft and leftplr ~= nil then
usedleft = false
leftplr = nil
elseif usedright and rightplr ~= nil then
usedright = false
rightplr = nil
end
elseif plrCount.Value == 2 then
if v.Name ~= plr.Name then
usedleft = true
leftplr = v
tp(v, Teleport.two)
elseif v.Name == plr.Name then
tp(plr, Teleport.one)
end
if usedright and rightplr ~= nil then
usedright = false
rightplr = nil
end
elseif plrCount.Value == 3 then
if usedleft == false and leftplr == nil and v.Name ~= plr.Name then
usedleft = true
leftplr = v
tp(v, Teleport.two)
elseif usedright == false and rightplr == nil and v.Name ~= plr.Name then
usedright = true
rightplr = v
tp(v, Teleport.three)
elseif v.Name == plr.Name then
tp(plr,Teleport.one)
end
end
end
game.ReplicatedStorage.PlayersInTotal:GetPropertyChangedSignal("Value"):Connect(function()
for _, v in pairs(plrs:GetPlayers()) do
local vchar = v.Character or v.CharacterAdded:Wait()
if plrCount.Value == 1 then
tp(plr, Teleport.one)
if usedleft and leftplr ~= nil then
usedleft = false
leftplr = nil
elseif usedright and rightplr ~= nil then
usedright = false
rightplr = nil
end
elseif plrCount.Value == 2 then
if v.Name ~= plr.Name then
usedleft = true
leftplr = v
tp(v, Teleport.two)
end
if usedright and rightplr ~= nil then
usedright = false
rightplr = nil
end
elseif plrCount.Value == 3 then
if usedleft == false and leftplr == nil and v.Name ~= plr.Name then
usedleft = true
leftplr = v
tp(v, Teleport.two)
elseif usedright == false and rightplr == nil and v.Name ~= plr.Name then
usedright = true
rightplr = v
tp(v, Teleport.three)
end
end
end
end)
Thoughts?