Go through various scenarios using the camera and moving a button [closed]

I use a button to move through scenarios, but it didn’t work when I clicked the button, I just stay in esc1, and I needed to go through esc2, esc3, and the others.

local CurrentCamera = workspace.CurrentCamera
local MenuCameraPart = workspace:WaitForChild("MenuCamera")  -- This is your menu camera
local PlayBTN = script.Parent.BG.Play_btn                  -- Your play button
local escenario = workspace.Model.escenario  -- Referencia al modelo ESCENARIO dentro de workspace.Model
local Players = game:GetService("Players")
local transport = workspace.Model:WaitForChild("teleport")
local botones = game.menu.Flechas.Frame   -- Los botones que queremos hacer visibles

-- Variables de control de cámara y escenarios
local escParts = {}  -- Tabla para almacenar las partes de los escenarios (cámaras)
local currentEscIndex = 1  -- Índice actual de la cámara
local numEscenarios = 5  -- Sabemos que hay 5 escenarios

-- Asignar manualmente las partes de los escenarios a la tabla escParts
escParts[1] = escenario:WaitForChild("esc1")
escParts[2] = escenario:WaitForChild("esc2")
escParts[3] = escenario:WaitForChild("esc3")
escParts[4] = escenario:WaitForChild("esc4")
escParts[5] = escenario:WaitForChild("esc5")
-- Set the camera to MenuCamera at the start
CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = MenuCameraPart.CFrame

-- Hacer invisible los botones de navegación al inicio

-- Función para cambiar la cámara al escenario actual
local function setEscenarioCamera(index)
    if escParts[index] then
        CurrentCamera.CameraType = Enum.CameraType.Scriptable
        CurrentCamera.CFrame = escParts[index].CFrame
    end
end

-- Función para congelar al jugador
local function FreezePlayer(player)
    local humanoid = player.Character:FindFirstChild("Humanoid")
    local humanoidRootPart = player.Character:FindFirstChild("HumanoidRootPart")

    if humanoid and humanoidRootPart then
        humanoid.WalkSpeed = 0
        humanoid.JumpPower = 0
        humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position, humanoidRootPart.Position + Vector3.new(0, 0, 1))
    end
end

-- Función cuando se hace clic en el botón "Play"
local function Play()
    CurrentCamera.CameraType = Enum.CameraType.Scriptable
    setEscenarioCamera(currentEscIndex)  -- Muestra la primera cámara del escenario

    local player = game.Players.LocalPlayer
    if player and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
        player.Character.HumanoidRootPart.CFrame = transport.CFrame
        FreezePlayer(player)
    end
print( "line 58")
    -- Mostrar los botones de navegación

    script.Parent:Destroy()  -- Destruir el GUI de Play después de hacer clic
end

-- Conectar el botón de "Play"
PlayBTN.MouseButton1Click:Connect(Play)

-- Funciones para navegar entre las cámaras (izquierda y derecha)
local function goLeft()
    currentEscIndex = (currentEscIndex - 1) < 1 and numEscenarios or (currentEscIndex - 1)
    setEscenarioCamera(currentEscIndex)
end

local function goRight()
    currentEscIndex = (currentEscIndex + 1) > numEscenarios and 1 or (currentEscIndex + 1)
    setEscenarioCamera(currentEscIndex)
end

-- Conectar los botones de flecha para navegar entre las cámaras
botones.abajo.MouseButton1Click:Connect(goLeft)
botones.arriba.MouseButton1Click:Connect(goRight)

print("last one")

I tried to useChatGPT, but nothing.

New contributor

AL-proyectos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật