Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Character = Players.LocalPlayer.Character or Players.LocalPlayer.CharacterAdded:Wait()
- local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
- local HPositions = {
- Vector3.new(25812, 1845, -3140),
- Vector3.new(25896, 1845, -3102),
- Vector3.new(25844, 1845, -3060),
- Vector3.new(25765, 1845, -3217),
- Vector3.new(25842, 1845, -3222),
- Vector3.new(25879, 1845, -3241),
- }
- local waitTime = 1
- local teleportCFrame = CFrame.new(-4614, 2665, 1226) -- CFrame de destino após a raid
- local function updateCFrame()
- for _, position in ipairs(HPositions) do
- HumanoidRootPart.CFrame = CFrame.new(position)
- task.wait(waitTime) -- Espera entre os movimentos
- end
- end
- _G.AutoRaid = false
- local isInRaid = false -- Flag para verificar se estamos na raid
- while true do
- if _G.AutoRaid and not isInRaid then
- -- Obter a sala
- local args = {
- [1] = {
- [1] = {
- [1] = "Raid",
- [2] = {
- [1] = "GetRoom",
- [2] = 4
- }
- },
- [2] = "\2"
- }
- }
- local dataRemoteEvent = ReplicatedStorage:FindFirstChild("dataRemoteEvent")
- if dataRemoteEvent then
- dataRemoteEvent:FireServer(unpack(args))
- print("Sala obtida com sucesso.")
- else
- warn("dataRemoteEvent não encontrado!")
- end
- task.wait(0.2)
- -- Selecionar o mapa
- local mapArgs = {
- [1] = {
- [1] = {
- [1] = "Raid",
- [2] = {
- [1] = "SelectMap",
- [2] = 4,
- [3] = {
- ["Name"] = "Piece",
- ["Image"] = "rbxassetid://18822946469"
- }
- }
- },
- [2] = "\2"
- }
- }
- if dataRemoteEvent then
- dataRemoteEvent:FireServer(unpack(mapArgs))
- print("Mapa selecionado com sucesso.")
- else
- warn("dataRemoteEvent não encontrado!")
- end
- task.wait(0.5)
- -- Iniciar o raid
- local Sargs = {
- [1] = {
- [1] = {
- [1] = "StartRaid",
- [2] = {
- [1] = 4
- }
- },
- [2] = "\2"
- }
- }
- if dataRemoteEvent then
- print("Tentando iniciar o raid...")
- dataRemoteEvent:FireServer(unpack(Sargs))
- -- Verificar se a chamada para iniciar a raid foi bem-sucedida
- task.wait(0.5) -- Espera um pouco para a resposta
- if not isInRaid then
- isInRaid = true -- Definindo que agora estamos na raid
- print("Raid iniciada com sucesso.")
- else
- warn("Falha ao iniciar a raid.")
- end
- else
- warn("dataRemoteEvent não encontrado!")
- end
- -- Atualizar CFrame se ainda estiver na torre após 0.3 segundos
- local startTime = tick() -- Hora de início da atualização do CFrame
- while isInRaid do
- task.wait(0.3) -- Espera 0.3 segundos
- -- Verifica se ainda estamos na raid
- local enemies = workspace.Enemies:GetChildren()
- local hasEnemy = false
- for _, enemy in ipairs(enemies) do
- if enemy:GetAttribute("Parent") == "PieceRaid" then
- hasEnemy = true
- break
- end
- end
- -- Se não houver inimigos, atualiza o CFrame
- if hasEnemy then
- updateCFrame()
- else
- print("Saímos da raid. Cancelando teleporte.")
- isInRaid = false -- Se não há inimigos, saia da raid
- end
- -- Cancela o teleporte se estiver na torre por mais de 0.3 segundos
- if tick() - startTime >= 0.3 then
- if isInRaid then
- updateCFrame() -- Reexecuta a função de CFrame após 0.3 segundos
- startTime = tick() -- Reseta o tempo de início
- end
- end
- end
- -- Teleporte para o CFrame especificado após terminar a raid
- if not isInRaid then
- HumanoidRootPart.CFrame = teleportCFrame -- Teleporta para o CFrame desejado
- print("Teleportando para a posição após a raid.")
- end
- task.wait(4) -- Tempo de espera após completar um ciclo
- else
- task.wait(1) -- Espera um segundo se AutoRaid estiver desativado
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement