Конечно! Ниже пример простого скрипта на Lua для Roblox, который создаёт графический интерфейс (GUI) с кнопками для управления полётом персонажа.
Пример: Скрипт для полёта с GUI в Roblox
Этот скрипт создаёт экранное GUI с двумя кнопками: Start Flight (начать полёт) и Stop Flight (остановить полёт). При нажатии на Start Flight персонаж начнёт летать (подниматься по нажатию клавиш W/S), при Stop Flight — возвращается в нормальный режим.
Как использовать:
В Roblox Studio вставьте ScreenGui в StarterGui.
Внутри ScreenGui добавьте два TextButton — назовите их, например, StartFlight и StopFlight.
Вставьте приведённый ниже LocalScript внутрь ScreenGui.
Отредактируйте кнопки по необходимости (цвет, текст и т.п.).
Сам скрипт - LocalScript:
lua
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
-- GUI элементы
local screenGui = script.Parent
local startBtn = screenGui:WaitForChild("StartFlight")
local stopBtn = screenGui:WaitForChild("StopFlight")
local flying = false
local speed = 50
local velocity = Vector3.new(0,0,0)
local bodyVelocity
-- Фунция старта полёта
local function startFly()
if flying then return end
flying = true
-- Создаём BodyVelocity, чтобы контролировать движение в воздухе
bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(1e5, 1e5, 1e5)
bodyVelocity.Velocity = Vector3.new(0,0,0)
bodyVelocity.Parent = rootPart
-- Отключаем ноги (чтобы не мешали)
humanoid.PlatformStand = true
-- Обработка нажатия клавиш для управления
RunService:BindToRenderStep("Fly", Enum.RenderPriority.Character.Value + 1, function()
if not flying then return end
local direction = Vector3.new(0,0,0)
if UserInputService:IsKeyDown(Enum.KeyCode.W) then
direction = direction + workspace.CurrentCamera.CFrame.LookVector
end
if UserInputService:IsKeyDown(Enum.KeyCode.S) then
direction = direction - workspace.CurrentCamera.CFrame.LookVector
end
if UserInputService:IsKeyDown(Enum.KeyCode.A) then
direction = direction - workspace.CurrentCamera.CFrame.RightVector
end
if UserInputService:IsKeyDown(Enum.KeyCode.D) then
direction = direction + workspace.CurrentCamera.CFrame.RightVector
end
if UserInputService:IsKeyDown(Enum.KeyCode.Space) then
direction = direction + Vector3.new(0,1,0)
end
if UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) then
direction = direction - Vector3.new(0,1,0)
end
direction = direction.Unit
if direction ~= direction then -- проверка на NaN
direction = Vector3.new(0,0,0)
end
bodyVelocity.Velocity = direction * speed
end)
end
-- Функция остановки полёта
local function stopFly()
if not flying then return end
flying = false
RunService:UnbindFromRenderStep("Fly")
if bodyVelocity then
bodyVelocity:Destroy()
bodyVelocity = nil
end
humanoid.PlatformStand = false
end
startBtn.MouseButton1Click:Connect(startFly)
stopBtn.MouseButton1Click:Connect(stopFly)
Объяснение:
При нажатии "Start Flight" создаётся BodyVelocity у HumanoidRootPart, который заставляет персонажа двигаться в направлении, зависящем от нажатых клавиш (W/A/S/D + Space/Shift).
Используется PlatformStand = true, чтобы отключить физику ног, чтобы персонаж не падал.
При "Stop Flight" полёт отключается, физика ног восстанавливается.
Если хочешь — могу помочь сделать скрипт для другой платформы или с другими возможностями. Просто скажи!