Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variável para armazenar a conexão atual da câmera
- local conexaoCamera
- -- Função para desfixar a câmera do jogador atual e voltar a seguir o seu personagem
- local function desfixarCamera()
- if conexaoCamera then
- conexaoCamera:Disconnect()
- conexaoCamera = nil
- end
- local jogadores = game:GetService("Players")
- local minhaCamera = game.Workspace.CurrentCamera
- minhaCamera.CameraType = Enum.CameraType.Custom
- local meuPersonagem = jogadores.LocalPlayer.Character
- if meuPersonagem then
- minhaCamera.CameraSubject = meuPersonagem.Humanoid
- end
- end
- -- Função para fazer a câmera seguir o seu personagem e focar em outro jogador
- local function seguirEApontarParaJogador(nomeJogador)
- desfixarCamera() -- Desfixa de qualquer jogador anterior
- local jogadores = game:GetService("Players")
- local meuPersonagem = jogadores.LocalPlayer.Character
- local jogadorAlvo = jogadores:FindFirstChild(nomeJogador)
- if meuPersonagem and jogadorAlvo and jogadorAlvo.Character then
- local troncoAlvo = jogadorAlvo.Character:FindFirstChild("UpperTorso") or jogadorAlvo.Character:FindFirstChild("Torso")
- local camera = game.Workspace.CurrentCamera
- camera.CameraType = Enum.CameraType.Scriptable
- -- Atualiza a câmera a cada frame para ficar fixa atrás do seu personagem e apontar para o tronco do jogador alvo
- local runService = game:GetService("RunService")
- conexaoCamera = runService.RenderStepped:Connect(function()
- if not troncoAlvo or not troncoAlvo.Parent then
- desfixarCamera() -- Desconecta se o tronco alvo não existir mais
- else
- local posicaoMeuPersonagem = meuPersonagem.HumanoidRootPart.Position
- local direcaoOlhar = meuPersonagem.HumanoidRootPart.CFrame.LookVector
- local posicaoCamera = posicaoMeuPersonagem - direcaoOlhar * 10 -- Ajuste a posição conforme necessário
- posicaoCamera = Vector3.new(posicaoCamera.X, posicaoMeuPersonagem.Y + 5, posicaoCamera.Z) -- Ajuste a altura da câmera conforme necessário
- local posicaoTroncoAlvo = troncoAlvo.Position
- camera.CFrame = CFrame.new(posicaoCamera, posicaoTroncoAlvo)
- end
- end)
- end
- end
- -- Função para iniciar o arrasto
- local function iniciarArrasto(frame, barra)
- local arrastando = false
- local posicaoInicial
- local diferencaPosicao
- local function iniciar(input)
- local tipoInput = input.UserInputType
- if tipoInput == Enum.UserInputType.Touch or tipoInput == Enum.UserInputType.MouseButton1 then
- arrastando = true
- posicaoInicial = Vector2.new(input.Position.X, input.Position.Y)
- diferencaPosicao = frame.Position - UDim2.new(0, posicaoInicial.X, 0, posicaoInicial.Y)
- end
- end
- local function mover(input)
- local tipoInput = input.UserInputType
- if arrastando and (tipoInput == Enum.UserInputType.Touch or tipoInput == Enum.UserInputType.MouseMovement) then
- local novaPosicao = Vector2.new(input.Position.X, input.Position.Y)
- frame.Position = UDim2.new(0, novaPosicao.X, 0, novaPosicao.Y) + diferencaPosicao
- end
- end
- local function parar(input)
- local tipoInput = input.UserInputType
- if tipoInput == Enum.UserInputType.Touch or tipoInput == Enum.UserInputType.MouseButton1 then
- arrastando = false
- end
- end
- barra.InputBegan:Connect(iniciar)
- barra.InputChanged:Connect(mover)
- barra.InputEnded:Connect(parar)
- frame.InputBegan:Connect(iniciar)
- frame.InputChanged:Connect(mover)
- frame.InputEnded:Connect(parar)
- end
- -- Função para atualizar a lista de jogadores no menu
- local function atualizarListaJogadores(scrollFrame)
- -- Remover todos os botões existentes
- for _, child in ipairs(scrollFrame:GetChildren()) do
- if child:IsA("TextButton") then
- child:Destroy()
- end
- end
- -- Adicionar botão para desfixar a câmera no topo da lista
- local botaoDesfixar = Instance.new("TextButton", scrollFrame)
- botaoDesfixar.Text = "Desfixar Câmera"
- botaoDesfixar.BackgroundColor3 = Color3.fromRGB(255, 0, 0) -- Cor vermelha
- botaoDesfixar.Size = UDim2.new(0, 230, 0, 50)
- botaoDesfixar.Position = UDim2.new(0, 10, 0, 10)
- botaoDesfixar.MouseButton1Click:Connect(desfixarCamera)
- -- Adicionar botões para cada jogador
- local jogadores = game.Players:GetPlayers()
- for i, jogador in ipairs(jogadores) do
- local botao = Instance.new("TextButton", scrollFrame)
- botao.Text = jogador.Name
- botao.Size = UDim2.new(0, 230, 0, 40)
- botao.Position = UDim2.new(0, 10, 0, 70 + (i - 1) * 50)
- botao.MouseButton1Click:Connect(function()
- seguirEApontarParaJogador(jogador.Name)
- end)
- end
- -- Ajustar a barra de rolagem para acomodar os novos botões
- scrollFrame.CanvasSize = UDim2.new(0, 0, 0, 70 + #jogadores * 50)
- end
- -- Criar um menu com barra de rolagem e borda branca para arrastar
- local gui = Instance.new("ScreenGui", game.Players.LocalPlayer:WaitForChild("PlayerGui"))
- gui.ResetOnSpawn = false
- local frame = Instance.new("Frame", gui)
- frame.Size = UDim2.new(0, 250, 0, 400)
- frame.Position = UDim2.new(0.5, -125, 0.5, -200)
- frame.BackgroundTransparency = 0.5
- local topBorder = Instance.new("Frame", frame)
- topBorder.Size = UDim2.new(1, 0, 0, 20)
- topBorder.BackgroundColor3 = Color3.new(1, 1, 1)
- topBorder.Position = UDim2.new(0, 0, 0, -20)
- local textoCreditos = Instance.new("TextLabel", topBorder)
- textoCreditos.Text = "By: mandy_dos_candys"
- textoCreditos.Size = UDim2.new(1, -10, 1, 0)
- textoCreditos.Position = UDim2.new(0, 5, 0, 0)
- textoCreditos.BackgroundTransparency = 1
- textoCreditos.TextColor3 = Color3.new(0, 0, 0)
- textoCreditos.TextXAlignment = Enum.TextXAlignment.Right
- iniciarArrasto(frame, topBorder)
- local scrollFrame = Instance.new("ScrollingFrame", frame)
- scrollFrame.Size = UDim2.new(1, 0, 1, -25)
- scrollFrame.Position = UDim2.new(0, 0, 0, 20)
- scrollFrame.ScrollBarThickness = 12
- -- Chamar a função para atualizar a lista de jogadores
- atualizarListaJogadores(scrollFrame)
- -- Conectar eventos para adicionar ou remover jogadores da lista
- game.Players.PlayerAdded:Connect(function(novoJogador)
- atualizarListaJogadores(scrollFrame)
- end)
- game.Players.PlayerRemoving:Connect(function(jogadorSaindo)
- atualizarListaJogadores(scrollFrame)
- end)
Advertisement
Add Comment
Please, Sign In to add comment