Skip to content
TheChatArchiveThe Chat Archive
gpt-4.1-mini-2025-04-14· OpenAIAi2 WildChat-4.8M (AI2)

напиши скрипт для роблоксатна полет

  1. User

    напиши скрипт для роблоксатна полет

  2. Assistant

    Для создания скрипта полёта в Roblox, можно использовать Lua и встроенные возможности Roblox Studio. Ниже приведён пример простого скрипта, который позволяет персонажу игрока летать при нажатии клавиши (например, клавиши "F"). Этот скрипт можно вставить в LocalScript, который размещается в StarterPlayerScripts.

    -- Скрипт полёта для Roblox
    local UserInputService = game:GetService("UserInputService")
    local RunService = game:GetService("RunService")
    local player = game.Players.LocalPlayer
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:WaitForChild("Humanoid")
    local rootPart = character:WaitForChild("HumanoidRootPart")
    
    local flying = false
    local flySpeed = 50
    local velocity = Vector3.new(0, 0, 0)
    
    -- Функция для включения полёта
    local function startFlying()
        flying = true
        humanoid.PlatformStand = true -- Отключить управление персонажем обычным образом
    end
    
    -- Функция для выключения полёта
    local function stopFlying()
        flying = false
        humanoid.PlatformStand = false
        rootPart.Velocity = Vector3.new(0, 0, 0)
    end
    
    -- Обработка нажатия клавиш
    UserInputService.InputBegan:Connect(function(input, gameProcessed)
        if gameProcessed then return end
    
        if input.KeyCode == Enum.KeyCode.F then
            if flying then
                stopFlying()
            else
                startFlying()
            end
        end
    end)
    
    -- Управление движением во время полёта
    RunService.Heartbeat:Connect(function(deltaTime)
        if not flying then return end
    
        local moveDirection = Vector3.new(0, 0, 0)
    
        if UserInputService:IsKeyDown(Enum.KeyCode.W) then
            moveDirection = moveDirection + workspace.CurrentCamera.CFrame.LookVector
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.S) then
            moveDirection = moveDirection - workspace.CurrentCamera.CFrame.LookVector
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.A) then
            moveDirection = moveDirection - workspace.CurrentCamera.CFrame.RightVector
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.D) then
            moveDirection = moveDirection + workspace.CurrentCamera.CFrame.RightVector
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.E) then
            moveDirection = moveDirection + Vector3.new(0, 1, 0) -- Вверх
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.Q) then
            moveDirection = moveDirection - Vector3.new(0, 1, 0) -- Вниз
        end
    
        if moveDirection.Magnitude > 0 then
            moveDirection = moveDirection.Unit * flySpeed
        end
    
        rootPart.Velocity = moveDirection
    end)
    

    Как использовать:

    1. Откройте Roblox Studio.
    2. Вставьте этот скрипт в StarterPlayer > StarterPlayerScripts как LocalScript.
    3. Запустите игру в режиме Play.
    4. Нажмите клавишу "F" чтобы включить/выключить полёт.
    5. Управляйте полётом с помощью WASD для движения вперед/назад/влево/вправо, клавишами E и Q для подъема и спуска.

    Если нужно, могу помочь улучшить или адаптировать скрипт.