PT.hub JP
Key RequiredUniversal

PT.hub JP

Universal Scriptbannikutannbannikutann 60 views 2.1K executesUpdated Aug 28, 2026
Unrated
00
Lua Script•2379 lines (81488 chars)
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local Lighting = game:GetService("Lighting")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local LocalPlayer = Players.LocalPlayer
local LocalMouse = LocalPlayer:GetMouse()
local Camera = Workspace.CurrentCamera

----------------------------------------------------------------
-- 設定
----------------------------------------------------------------
local Config = {
    Speed = 16,
    JumpPower = 50,
    Gravity = Workspace.Gravity,
}

----------------------------------------------------------------
-- GUI 土台
----------------------------------------------------------------
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "HubGui"
ScreenGui.ResetOnSpawn = false
ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
ScreenGui.Parent = LocalPlayer:WaitForChild("PlayerGui")

local EXPANDED_SIZE = UDim2.new(0, 320, 0, 420)
local COLLAPSED_SIZE = UDim2.new(0, 320, 0, 36)

local MainFrame = Instance.new("Frame")
MainFrame.Name = "MainFrame"
MainFrame.Size = EXPANDED_SIZE
MainFrame.Position = UDim2.new(1, -336, 0.5, -210) -- 画面右側に配置(右端から16pxマージン)
MainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 35)
MainFrame.BorderSizePixel = 0
MainFrame.Parent = ScreenGui

local UICorner = Instance.new("UICorner")
UICorner.CornerRadius = UDim.new(0, 8)
UICorner.Parent = MainFrame

-- タイトルバー(ドラッグ用)
local TitleBar = Instance.new("Frame")
TitleBar.Name = "TitleBar"
TitleBar.Size = UDim2.new(1, 0, 0, 36)
TitleBar.BackgroundColor3 = Color3.fromRGB(20, 20, 24)
TitleBar.BorderSizePixel = 0
TitleBar.Parent = MainFrame

local TitleCorner = Instance.new("UICorner")
TitleCorner.CornerRadius = UDim.new(0, 8)
TitleCorner.Parent = TitleBar

local TitleLabel = Instance.new("TextLabel")
TitleLabel.Size = UDim2.new(1, -52, 1, 0)
TitleLabel.Position = UDim2.new(0, 12, 0, 0)
TitleLabel.BackgroundTransparency = 1
TitleLabel.Text = "PT HUB JP"
TitleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
TitleLabel.TextXAlignment = Enum.TextXAlignment.Left
TitleLabel.Font = Enum.Font.GothamBold
TitleLabel.TextSize = 16
TitleLabel.Parent = TitleBar

-- 折りたたみ(-)ボタン
local minimized = false
local MinimizeBtn = Instance.new("TextButton")
MinimizeBtn.Name = "MinimizeBtn"
MinimizeBtn.Size = UDim2.new(0, 26, 0, 26)
MinimizeBtn.Position = UDim2.new(1, -32, 0.5, -13)
MinimizeBtn.BackgroundColor3 = Color3.fromRGB(35, 35, 40)
MinimizeBtn.Text = "-"
MinimizeBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
MinimizeBtn.Font = Enum.Font.GothamBold
MinimizeBtn.TextSize = 18
MinimizeBtn.Parent = TitleBar

local MinimizeBtnCorner = Instance.new("UICorner")
MinimizeBtnCorner.CornerRadius = UDim.new(0, 6)
MinimizeBtnCorner.Parent = MinimizeBtn

-- ドラッグ処理
do
    local dragging, dragInput, dragStart, startPos
    TitleBar.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            dragging = true
            dragStart = input.Position
            startPos = MainFrame.Position
            input.Changed:Connect(function()
                if input.UserInputState == Enum.UserInputState.End then
                    dragging = false
                end
            end)
        end
    end)
    TitleBar.InputChanged:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
            dragInput = input
        end
    end)
    UserInputService.InputChanged:Connect(function(input)
        if input == dragInput and dragging then
            local delta = input.Position - dragStart
            MainFrame.Position = UDim2.new(
                startPos.X.Scale, startPos.X.Offset + delta.X,
                startPos.Y.Scale, startPos.Y.Offset + delta.Y
            )
        end
    end)
end

-- 汎用ドラッグ関数(他のパネルにも使い回す)
local function makeDraggable(frame, dragHandle)
    dragHandle = dragHandle or frame
    dragHandle.Active = true
    local dragging, dragInput, dragStart, startPos
    dragHandle.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            dragging = true
            dragStart = input.Position
            startPos = frame.Position
            input.Changed:Connect(function()
                if input.UserInputState == Enum.UserInputState.End then
                    dragging = false
                end
            end)
        end
    end)
    dragHandle.InputChanged:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
            dragInput = input
        end
    end)
    UserInputService.InputChanged:Connect(function(input)
        if input == dragInput and dragging then
            local delta = input.Position - dragStart
            frame.Position = UDim2.new(
                startPos.X.Scale, startPos.X.Offset + delta.X,
                startPos.Y.Scale, startPos.Y.Offset + delta.Y
            )
        end
    end)
end

----------------------------------------------------------------
-- タブ切り替え
----------------------------------------------------------------
local TabBar = Instance.new("Frame")
TabBar.Name = "TabBar"
TabBar.Size = UDim2.new(1, 0, 0, 32)
TabBar.Position = UDim2.new(0, 0, 0, 36)
TabBar.BackgroundColor3 = Color3.fromRGB(25, 25, 30)
TabBar.BorderSizePixel = 0
TabBar.Parent = MainFrame

local TabLayout = Instance.new("UIListLayout")
TabLayout.FillDirection = Enum.FillDirection.Horizontal
TabLayout.SortOrder = Enum.SortOrder.LayoutOrder
TabLayout.Parent = TabBar

local Pages = Instance.new("Frame")
Pages.Name = "Pages"
Pages.Size = UDim2.new(1, -16, 1, -80)
Pages.Position = UDim2.new(0, 8, 0, 76)
Pages.BackgroundTransparency = 1
Pages.Parent = MainFrame

local tabButtons = {}
local pageFrames = {}

local function createTab(name, displayLabel)
    local btn = Instance.new("TextButton")
    btn.Name = name .. "Tab"
    btn.Size = UDim2.new(1 / 3, 0, 1, 0)
    btn.BackgroundColor3 = Color3.fromRGB(35, 35, 40)
    btn.BorderSizePixel = 0
    btn.Text = displayLabel or name
    btn.Font = Enum.Font.GothamBold
    btn.TextSize = 14
    btn.TextColor3 = Color3.fromRGB(200, 200, 200)
    btn.Parent = TabBar

    local page = Instance.new("ScrollingFrame")
    page.Name = name .. "Page"
    page.Size = UDim2.new(1, 0, 1, 0)
    page.BackgroundTransparency = 1
    page.BorderSizePixel = 0
    page.ScrollBarThickness = 4
    page.CanvasSize = UDim2.new(0, 0, 0, 0)
    page.AutomaticCanvasSize = Enum.AutomaticSize.Y
    page.Visible = false
    page.Parent = Pages

    local listLayout = Instance.new("UIListLayout")
    listLayout.Padding = UDim.new(0, 10)
    listLayout.SortOrder = Enum.SortOrder.LayoutOrder
    listLayout.Parent = page

    tabButtons[name] = btn
    pageFrames[name] = page

    btn.MouseButton1Click:Connect(function()
        for tabName, p in pairs(pageFrames) do
            p.Visible = (tabName == name)
        end
        for tabName, b in pairs(tabButtons) do
            b.BackgroundColor3 = (tabName == name)
                and Color3.fromRGB(70, 130, 230)
                or Color3.fromRGB(35, 35, 40)
        end
    end)

    return page
end

local MovementPage = createTab("Movement", "移動")
local VisualPage = createTab("Visual", "表示")
local HelperPage = createTab("Memo", "メモ帳")

pageFrames["Movement"].Visible = true
tabButtons["Movement"].BackgroundColor3 = Color3.fromRGB(70, 130, 230)

-- 折りたたみボタンの動作
MinimizeBtn.MouseButton1Click:Connect(function()
    minimized = not minimized
    TabBar.Visible = not minimized
    Pages.Visible = not minimized
    MinimizeBtn.Text = minimized and "+" or "-"

    local targetSize = minimized and COLLAPSED_SIZE or EXPANDED_SIZE
    TweenService:Create(MainFrame, TweenInfo.new(0.2), {Size = targetSize}):Play()
end)

----------------------------------------------------------------
-- 共通: スライダー生成
----------------------------------------------------------------
local function createSlider(parent, labelText, min, max, default, onChange)
    local container = Instance.new("Frame")
    container.Size = UDim2.new(1, 0, 0, 50)
    container.BackgroundTransparency = 1
    container.Parent = parent

    local label = Instance.new("TextLabel")
    label.Size = UDim2.new(1, 0, 0, 18)
    label.BackgroundTransparency = 1
    label.Text = labelText .. ": " .. tostring(default)
    label.TextColor3 = Color3.fromRGB(220, 220, 220)
    label.Font = Enum.Font.Gotham
    label.TextSize = 13
    label.TextXAlignment = Enum.TextXAlignment.Left
    label.Parent = container

    local track = Instance.new("Frame")
    track.Size = UDim2.new(1, 0, 0, 8)
    track.Position = UDim2.new(0, 0, 0, 26)
    track.BackgroundColor3 = Color3.fromRGB(50, 50, 55)
    track.BorderSizePixel = 0
    track.Parent = container

    local trackCorner = Instance.new("UICorner")
    trackCorner.CornerRadius = UDim.new(1, 0)
    trackCorner.Parent = track

    local fill = Instance.new("Frame")
    local pct = (default - min) / (max - min)
    fill.Size = UDim2.new(pct, 0, 1, 0)
    fill.BackgroundColor3 = Color3.fromRGB(70, 130, 230)
    fill.BorderSizePixel = 0
    fill.Parent = track

    local fillCorner = Instance.new("UICorner")
    fillCorner.CornerRadius = UDim.new(1, 0)
    fillCorner.Parent = fill

    local knob = Instance.new("Frame")
    knob.Size = UDim2.new(0, 14, 0, 14)
    knob.AnchorPoint = Vector2.new(0.5, 0.5)
    knob.Position = UDim2.new(pct, 0, 0.5, 0)
    knob.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    knob.BorderSizePixel = 0
    knob.Parent = track

    local knobCorner = Instance.new("UICorner")
    knobCorner.CornerRadius = UDim.new(1, 0)
    knobCorner.Parent = knob

    local dragging = false

    local function update(inputPos)
        local relativeX = math.clamp((inputPos.X - track.AbsolutePosition.X) / track.AbsoluteSize.X, 0, 1)
        local value = math.floor(min + (max - min) * relativeX)
        fill.Size = UDim2.new(relativeX, 0, 1, 0)
        knob.Position = UDim2.new(relativeX, 0, 0.5, 0)
        label.Text = labelText .. ": " .. tostring(value)
        onChange(value)
    end

    track.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            dragging = true
            update(input.Position)
        end
    end)

    UserInputService.InputChanged:Connect(function(input)
        if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
            update(input.Position)
        end
    end)

    UserInputService.InputEnded:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            dragging = false
        end
    end)

    return container
end

----------------------------------------------------------------
-- 共通: トグルスイッチ生成(戻り値: コンテナ, スイッチ本体)
----------------------------------------------------------------
local function createToggleSwitch(sizeX, default, onChange)
    local switchBg = Instance.new("Frame")
    switchBg.Size = UDim2.new(0, sizeX or 44, 0, 22)
    switchBg.BackgroundColor3 = default and Color3.fromRGB(70, 130, 230) or Color3.fromRGB(60, 60, 65)

    local switchCorner = Instance.new("UICorner")
    switchCorner.CornerRadius = UDim.new(1, 0)
    switchCorner.Parent = switchBg

    local knob = Instance.new("Frame")
    knob.Size = UDim2.new(0, 18, 0, 18)
    knob.Position = default and UDim2.new(1, -20, 0.5, -9) or UDim2.new(0, 2, 0.5, -9)
    knob.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    knob.Parent = switchBg

    local knobCorner = Instance.new("UICorner")
    knobCorner.CornerRadius = UDim.new(1, 0)
    knobCorner.Parent = knob

    local state = default
    local clickBtn = Instance.new("TextButton")
    clickBtn.Size = UDim2.new(1, 0, 1, 0)
    clickBtn.BackgroundTransparency = 1
    clickBtn.Text = ""
    clickBtn.Parent = switchBg

    clickBtn.MouseButton1Click:Connect(function()
        state = not state
        local targetPos = state and UDim2.new(1, -20, 0.5, -9) or UDim2.new(0, 2, 0.5, -9)
        local targetColor = state and Color3.fromRGB(70, 130, 230) or Color3.fromRGB(60, 60, 65)
        TweenService:Create(knob, TweenInfo.new(0.15), {Position = targetPos}):Play()
        TweenService:Create(switchBg, TweenInfo.new(0.15), {BackgroundColor3 = targetColor}):Play()
        onChange(state)
    end)

    return switchBg
end

local function createToggle(parent, labelText, default, onChange)
    local container = Instance.new("Frame")
    container.Size = UDim2.new(1, 0, 0, 36)
    container.BackgroundTransparency = 1
    container.Parent = parent

    local label = Instance.new("TextLabel")
    label.Size = UDim2.new(0.7, 0, 1, 0)
    label.BackgroundTransparency = 1
    label.Text = labelText
    label.TextColor3 = Color3.fromRGB(220, 220, 220)
    label.Font = Enum.Font.Gotham
    label.TextSize = 14
    label.TextXAlignment = Enum.TextXAlignment.Left
    label.Parent = container

    local switch = createToggleSwitch(44, default, onChange)
    switch.Position = UDim2.new(1, -44, 0.5, -11)
    switch.Parent = container

    return container
end

----------------------------------------------------------------
-- 共通: ラベル + 数値入力欄 + Applyボタン
----------------------------------------------------------------
local function createNumberInput(parent, labelText, defaultValue, minValue, maxValue, onApply)
    local container = Instance.new("Frame")
    container.Size = UDim2.new(1, 0, 0, 40)
    container.BackgroundTransparency = 1
    container.Parent = parent

    local label = Instance.new("TextLabel")
    label.Size = UDim2.new(0.32, 0, 1, 0)
    label.BackgroundTransparency = 1
    label.Text = labelText .. ":"
    label.TextColor3 = Color3.fromRGB(220, 220, 220)
    label.Font = Enum.Font.Gotham
    label.TextSize = 14
    label.TextXAlignment = Enum.TextXAlignment.Left
    label.Parent = container

    local inputBox = Instance.new("TextBox")
    inputBox.Size = UDim2.new(0.44, -6, 1, -6)
    inputBox.Position = UDim2.new(0.32, 0, 0, 3)
    inputBox.BackgroundColor3 = Color3.fromRGB(45, 45, 50)
    inputBox.Text = tostring(defaultValue)
    inputBox.TextColor3 = Color3.fromRGB(255, 255, 255)
    inputBox.Font = Enum.Font.Gotham
    inputBox.TextSize = 14
    inputBox.ClearTextOnFocus = false
    inputBox.Parent = container

    local inputBoxCorner = Instance.new("UICorner")
    inputBoxCorner.CornerRadius = UDim.new(0, 6)
    inputBoxCorner.Parent = inputBox

    local applyButton = Instance.new("TextButton")
    applyButton.Size = UDim2.new(0.24, -6, 1, -6)
    applyButton.Position = UDim2.new(0.76, 6, 0, 3)
    applyButton.BackgroundColor3 = Color3.fromRGB(45, 160, 90)
    applyButton.Text = "適用"
    applyButton.TextColor3 = Color3.fromRGB(255, 255, 255)
    applyButton.Font = Enum.Font.GothamBold
    applyButton.TextSize = 13
    applyButton.Parent = container

    local applyButtonCorner = Instance.new("UICorner")
    applyButtonCorner.CornerRadius = UDim.new(0, 6)
    applyButtonCorner.Parent = applyButton

    local function applyValue()
        local value = tonumber(inputBox.Text)
        if value then
            if minValue then value = math.max(minValue, value) end
            if maxValue then value = math.min(maxValue, value) end
            inputBox.Text = tostring(value)
            onApply(value)
        else
            inputBox.Text = tostring(defaultValue)
        end
    end

    applyButton.MouseButton1Click:Connect(applyValue)
    inputBox.FocusLost:Connect(function(enterPressed)
        if enterPressed then
            applyValue()
        end
    end)

    return container
end

----------------------------------------------------------------
-- Movementタブの中身: Speed / JumpPower / Gravity / Fly
----------------------------------------------------------------
local function applyToCharacter()
    local character = LocalPlayer.Character
    if not character then return end
    local humanoid = character:FindFirstChildOfClass("Humanoid")
    if not humanoid then return end
    humanoid.WalkSpeed = Config.Speed
    -- UseJumpPowerがfalseだとJumpPowerが無視されJumpHeightが使われるため、明示的にtrueにする
    humanoid.UseJumpPower = true
    humanoid.JumpPower = Config.JumpPower
end

createNumberInput(MovementPage, "移動速度", Config.Speed, 0, 10000, function(value)
    Config.Speed = value
    local character = LocalPlayer.Character
    local humanoid = character and character:FindFirstChildOfClass("Humanoid")
    if humanoid then
        humanoid.WalkSpeed = value
    end
end)

createNumberInput(MovementPage, "ジャンプ力", Config.JumpPower, 0, 10000, function(value)
    Config.JumpPower = value
    local character = LocalPlayer.Character
    local humanoid = character and character:FindFirstChildOfClass("Humanoid")
    if humanoid then
        -- UseJumpPowerがfalseだとJumpPowerを変えても反映されない(JumpHeightが優先される)ため、
        -- 明示的にUseJumpPower=trueにしたうえで、念のためJumpHeightも近い値に揃えておく
        humanoid.UseJumpPower = true
        humanoid.JumpPower = value
        humanoid.JumpHeight = (value ^ 2) / (2 * Workspace.Gravity)
    end
end)

createNumberInput(MovementPage, "重力", Config.Gravity, -1000, 10000, function(value)
    Config.Gravity = value
    Workspace.Gravity = value
end)

-- Fly
local flying = false
local flyVelocity, flyGyro
local flySpeed = 60
local flyConnection

-- Fly中だけ表示する、画面右下のスピード入力パネル
local FlySpeedFrame = Instance.new("Frame")
FlySpeedFrame.Name = "FlySpeedFrame"
FlySpeedFrame.Size = UDim2.new(0, 160, 0, 128)
FlySpeedFrame.Position = UDim2.new(1, -176, 1, -144)
FlySpeedFrame.BackgroundColor3 = Color3.fromRGB(24, 24, 28)
FlySpeedFrame.BorderSizePixel = 0
FlySpeedFrame.Visible = false
FlySpeedFrame.Parent = ScreenGui

-- Hub本体を折りたたんだ時は、Fly中でもこのパネルも一緒に隠す
MinimizeBtn.MouseButton1Click:Connect(function()
    if minimized then
        FlySpeedFrame.Visible = false
    else
        FlySpeedFrame.Visible = flying
    end
end)

local FlySpeedCorner = Instance.new("UICorner")
FlySpeedCorner.CornerRadius = UDim.new(0, 8)
FlySpeedCorner.Parent = FlySpeedFrame

local FlySpeedLabel = Instance.new("TextLabel")
FlySpeedLabel.Size = UDim2.new(1, -16, 0, 18)
FlySpeedLabel.Position = UDim2.new(0, 8, 0, 6)
FlySpeedLabel.BackgroundTransparency = 1
FlySpeedLabel.Text = "飛行速度"
FlySpeedLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
FlySpeedLabel.Font = Enum.Font.GothamBold
FlySpeedLabel.TextSize = 13
FlySpeedLabel.TextXAlignment = Enum.TextXAlignment.Left
FlySpeedLabel.Parent = FlySpeedFrame
makeDraggable(FlySpeedFrame, FlySpeedLabel)

-- ブーストキー割り当てボタン(Speed入力欄の上に配置)
local boostKeyCode = Enum.KeyCode.LeftControl
local awaitingKeybind = false

local BoostKeyButton = Instance.new("TextButton")
BoostKeyButton.Size = UDim2.new(1, -16, 0, 24)
BoostKeyButton.Position = UDim2.new(0, 8, 0, 26)
BoostKeyButton.BackgroundColor3 = Color3.fromRGB(45, 45, 50)
BoostKeyButton.Text = "ブーストキー: " .. boostKeyCode.Name
BoostKeyButton.TextColor3 = Color3.fromRGB(255, 255, 255)
BoostKeyButton.Font = Enum.Font.Gotham
BoostKeyButton.TextSize = 13
BoostKeyButton.Parent = FlySpeedFrame

local BoostKeyButtonCorner = Instance.new("UICorner")
BoostKeyButtonCorner.CornerRadius = UDim.new(0, 6)
BoostKeyButtonCorner.Parent = BoostKeyButton

local FlySpeedBox = Instance.new("TextBox")
FlySpeedBox.Size = UDim2.new(1, -16, 0, 28)
FlySpeedBox.Position = UDim2.new(0, 8, 0, 56)
FlySpeedBox.BackgroundColor3 = Color3.fromRGB(45, 45, 50)
FlySpeedBox.Text = tostring(flySpeed)
FlySpeedBox.TextColor3 = Color3.fromRGB(255, 255, 255)
FlySpeedBox.PlaceholderText = "速度"
FlySpeedBox.Font = Enum.Font.Gotham
FlySpeedBox.TextSize = 14
FlySpeedBox.ClearTextOnFocus = false
FlySpeedBox.Parent = FlySpeedFrame

local FlySpeedBoxCorner = Instance.new("UICorner")
FlySpeedBoxCorner.CornerRadius = UDim.new(0, 6)
FlySpeedBoxCorner.Parent = FlySpeedBox

local FlyBoostLabel = Instance.new("TextLabel")
FlyBoostLabel.Size = UDim2.new(1, -16, 0, 14)
FlyBoostLabel.Position = UDim2.new(0, 8, 0, 88)
FlyBoostLabel.BackgroundTransparency = 1
FlyBoostLabel.Text = boostKeyCode.Name .. " 押しっぱなしで3倍ブースト"
FlyBoostLabel.TextColor3 = Color3.fromRGB(150, 150, 155)
FlyBoostLabel.Font = Enum.Font.Gotham
FlyBoostLabel.TextSize = 10
FlyBoostLabel.TextXAlignment = Enum.TextXAlignment.Left
FlyBoostLabel.TextWrapped = true
FlyBoostLabel.Parent = FlySpeedFrame

BoostKeyButton.MouseButton1Click:Connect(function()
    awaitingKeybind = true
    BoostKeyButton.Text = "キーを押してください..."
end)

UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if not awaitingKeybind then return end
    if input.UserInputType ~= Enum.UserInputType.Keyboard then return end

    boostKeyCode = input.KeyCode
    BoostKeyButton.Text = "ブーストキー: " .. boostKeyCode.Name
    FlyBoostLabel.Text = boostKeyCode.Name .. " 押しっぱなしで3倍ブースト"
    awaitingKeybind = false
end)

FlySpeedBox.FocusLost:Connect(function(enterPressed)
    local value = tonumber(FlySpeedBox.Text)
    if value then
        value = math.clamp(value, 1, 1000)
        flySpeed = value
        FlySpeedBox.Text = tostring(value)
    else
        FlySpeedBox.Text = tostring(flySpeed)
    end
end)

local savedJumpPower = nil
local savedJumpHeight = nil
local savedUseJumpPower = nil

----------------------------------------------------------------
-- スーパーヒーローモード: 腕を前に伸ばすポーズ + 速度トレイル
----------------------------------------------------------------
local superheroMode = false
local savedArmC0 = {}
local speedTrails = {}

local function getArmChains(character)
    local chains = { left = {}, right = {} }
    local upperTorso = character:FindFirstChild("UpperTorso")

    if upperTorso then
        -- R15: 肩 + 肘の両方を同じ向きに揃えて、腕全体をまっすぐにする
        local leftShoulder = upperTorso:FindFirstChild("LeftShoulder")
        local rightShoulder = upperTorso:FindFirstChild("RightShoulder")
        if leftShoulder then table.insert(chains.left, leftShoulder) end
        if rightShoulder then table.insert(chains.right, rightShoulder) end

        local leftUpperArm = character:FindFirstChild("LeftUpperArm")
        local rightUpperArm = character:FindFirstChild("RightUpperArm")
        if leftUpperArm then
            local leftElbow = leftUpperArm:FindFirstChild("LeftElbow")
            if leftElbow then table.insert(chains.left, leftElbow) end
        end
        if rightUpperArm then
            local rightElbow = rightUpperArm:FindFirstChild("RightElbow")
            if rightElbow then table.insert(chains.right, rightElbow) end
        end
    else
        -- R6: 肩のみ(肘関節が無いため)
        local torso = character:FindFirstChild("Torso")
        if torso then
            local leftMotor = torso:FindFirstChild("Left Shoulder")
            local rightMotor = torso:FindFirstChild("Right Shoulder")
            if leftMotor then table.insert(chains.left, leftMotor) end
            if rightMotor then table.insert(chains.right, rightMotor) end
        end
    end

    return chains
end

local function setSuperheroArms(character, enabled)
    local chains = getArmChains(character)
    local root = character:FindFirstChild("HumanoidRootPart")
    if not root then return end

    if enabled then
        -- 再生中のアニメーションが関節を上書きして「ねじれ」の原因になることがあるため、即座に止める
        local humanoid = character:FindFirstChildOfClass("Humanoid")
        local animator = humanoid and humanoid:FindFirstChildOfClass("Animator")
        if animator then
            for _, track in pairs(animator:GetPlayingAnimationTracks()) do
                track:Stop(0)
            end
        end
    end

    local desiredWorldCFrame = root.CFrame * CFrame.Angles(math.rad(-90), 0, 0)

    local function apply(motor, isFirstInChain)
        if not motor or not motor.Part0 then return end
        if enabled then
            if not savedArmC0[motor] then
                savedArmC0[motor] = motor.C0
            end
            if isFirstInChain then
                -- 肩: 現在の胴体の向きを基準に、腕をdesiredWorldCFrameへ揃える
                motor.C0 = motor.Part0.CFrame:ToObjectSpace(desiredWorldCFrame) * motor.C1
            else
                -- 肘: 直前の関節(上腕)はこの関数内でdesiredWorldCFrameに固定される前提のため、
                -- 上腕のCFrameを直接読まずに済むようC1と同じ値にして「まっすぐ」を保つ
                motor.C0 = motor.C1
            end
        else
            if savedArmC0[motor] then
                motor.C0 = savedArmC0[motor]
                savedArmC0[motor] = nil
            end
        end
    end

    for i, motor in ipairs(chains.left) do
        apply(motor, i == 1)
    end
    for i, motor in ipairs(chains.right) do
        apply(motor, i == 1)
    end
end

local function createSpeedTrail(part)
    local att0 = Instance.new("Attachment")
    att0.Name = "SpeedTrailAtt0"
    att0.Position = Vector3.new(0, 0.5, -1)
    att0.Parent = part

    local att1 = Instance.new("Attachment")
    att1.Name = "SpeedTrailAtt1"
    att1.Position = Vector3.new(0, 0.5, 1)
    att1.Parent = part

    local trail = Instance.new("Trail")
    trail.Attachment0 = att0
    trail.Attachment1 = att1
    trail.Lifetime = 0.3
    trail.MinLength = 0
    trail.FaceCamera = true
    trail.Color = ColorSequence.new(Color3.fromRGB(255, 255, 255))
    trail.Transparency = NumberSequence.new({
        NumberSequenceKeypoint.new(0, 0.2),
        NumberSequenceKeypoint.new(1, 1),
    })
    trail.WidthScale = NumberSequence.new({
        NumberSequenceKeypoint.new(0, 1),
        NumberSequenceKeypoint.new(1, 0),
    })
    trail.Enabled = false
    trail.Parent = part

    return trail
end

local function setupSpeedTrail(character)
    local root = character:FindFirstChild("HumanoidRootPart")
    if not root then return end
    if speedTrails[character] then return end
    speedTrails[character] = createSpeedTrail(root)
end

local function removeSpeedTrail(character)
    local trail = speedTrails[character]
    if trail then
        trail:Destroy()
        speedTrails[character] = nil
    end
end

local function stopFly()
    flying = false
    if flyConnection then
        flyConnection:Disconnect()
        flyConnection = nil
    end
    local character = LocalPlayer.Character
    local humanoid = character and character:FindFirstChildOfClass("Humanoid")
    if humanoid then
        humanoid.PlatformStand = false
        -- ジャンプ設定を元に戻す
        if savedUseJumpPower ~= nil then
            humanoid.UseJumpPower = savedUseJumpPower
        end
        if savedJumpPower ~= nil then
            humanoid.JumpPower = savedJumpPower
        end
        if savedJumpHeight ~= nil then
            humanoid.JumpHeight = savedJumpHeight
        end
    end
    savedJumpPower, savedJumpHeight, savedUseJumpPower = nil, nil, nil
    if flyVelocity then flyVelocity:Destroy() flyVelocity = nil end
    if flyGyro then flyGyro:Destroy() flyGyro = nil end
    FlySpeedFrame.Visible = false

    if character then
        setSuperheroArms(character, false)
        removeSpeedTrail(character)
    end
end

local function startFly()
    local character = LocalPlayer.Character
    if not character then return end
    local humanoid = character:FindFirstChildOfClass("Humanoid")
    local root = character:FindFirstChild("HumanoidRootPart")
    if not humanoid or not root then return end

    flying = true
    humanoid.PlatformStand = true
    FlySpeedFrame.Visible = true

    setupSpeedTrail(character)
    local armsRaised = false

    -- Space(ジャンプ)で浮き上がらないよう、ジャンプ力そのものを一時的に0にする
    savedUseJumpPower = humanoid.UseJumpPower
    savedJumpPower = humanoid.JumpPower
    savedJumpHeight = humanoid.JumpHeight
    humanoid.JumpPower = 0
    humanoid.JumpHeight = 0

    flyVelocity = Instance.new("BodyVelocity")
    flyVelocity.MaxForce = Vector3.new(1, 1, 1) * math.huge
    flyVelocity.Velocity = Vector3.new()
    flyVelocity.Parent = root

    flyGyro = Instance.new("BodyGyro")
    flyGyro.MaxTorque = Vector3.new(1, 1, 1) * math.huge
    flyGyro.P = 10000
    flyGyro.CFrame = root.CFrame
    flyGyro.Parent = root

    local lastFlyDirection = nil
    local currentBoostFactor = 1

    flyConnection = RunService.RenderStepped:Connect(function(dt)
        if not flying or not flyVelocity or not flyGyro then return end

        -- 他の処理でPlatformStandが解除されても即座に戻し、ジャンプによる浮きを防ぐ
        if humanoid.PlatformStand ~= true then
            humanoid.PlatformStand = true
        end

        local cam = Workspace.CurrentCamera
        local moveVector = Vector3.new()

        if UserInputService:IsKeyDown(Enum.KeyCode.W) then
            moveVector = moveVector + cam.CFrame.LookVector
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.S) then
            moveVector = moveVector - cam.CFrame.LookVector
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.A) then
            moveVector = moveVector - cam.CFrame.RightVector
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.D) then
            moveVector = moveVector + cam.CFrame.RightVector
        end

        local isBoosting = UserInputService:IsKeyDown(boostKeyCode) and moveVector.Magnitude > 0

        if isBoosting then
            if inertiaEnabled and inertiaValue > 0 then
                -- 慣性値(0〜100)に応じて、3倍まで徐々に加速する(100が一番ゆっくり)
                local rampDuration = (inertiaValue / 100) * 3 -- 最大3秒かけて加速
                local increasePerSecond = 2 / rampDuration -- 1倍→3倍(差分2)をrampDuration秒で
                currentBoostFactor = math.min(3, currentBoostFactor + increasePerSecond * dt)
            else
                -- 慣性OFF(または0)はボタンを押していない時と同じ、即座に3倍
                currentBoostFactor = 3
            end
        else
            currentBoostFactor = 1
        end

        if moveVector.Magnitude > 0 then
            local currentSpeed = flySpeed * (isBoosting and currentBoostFactor or 1)
            moveVector = moveVector.Unit * currentSpeed
        end

        flyVelocity.Velocity = moveVector

        if superheroMode then
            -- ブースト中はほぼ水平のスーパーマン風ポーズ、通常飛行時はダイブのような前傾ポーズ
            -- (カメラの上下を見た分だけ、その角度にも追従する)
            local baseDiveAngle = isBoosting and -85 or -45

            local flatDirection
            if moveVector.Magnitude > 0.01 then
                flatDirection = Vector3.new(moveVector.X, 0, moveVector.Z)
                if flatDirection.Magnitude > 0.01 then
                    lastFlyDirection = flatDirection.Unit
                end
            end
            if not flatDirection or flatDirection.Magnitude < 0.01 then
                -- 移動キーを離した瞬間も、直前まで飛んでいた水平方向を保つ
                if lastFlyDirection then
                    flatDirection = lastFlyDirection
                else
                    local rootLook = root.CFrame.LookVector
                    flatDirection = Vector3.new(rootLook.X, 0, rootLook.Z)
                    if flatDirection.Magnitude < 0.01 then
                        flatDirection = Vector3.new(0, 0, -1)
                    end
                end
            end

            -- カメラの上下角度を取得して、ダイブ角度に上乗せする
            local camLook = cam.CFrame.LookVector
            local camPitch = math.asin(math.clamp(camLook.Y, -1, 1)) -- ラジアン、見上げてると+、見下ろすと-
            local totalPitch = math.rad(baseDiveAngle) + camPitch

            local lookCFrame = CFrame.lookAt(root.Position, root.Position + flatDirection.Unit)
            flyGyro.CFrame = lookCFrame * CFrame.Angles(totalPitch, 0, 0)

            -- 腕はブースト中だけ前方に上げる
            if isBoosting and not armsRaised then
                setSuperheroArms(character, true)
                armsRaised = true
            elseif not isBoosting and armsRaised then
                setSuperheroArms(character, false)
                armsRaised = false
            end

            local trail = speedTrails[character]
            if trail then
                trail.Enabled = true
                trail.Lifetime = isBoosting and 0.5 or 0.25
            end
        else
            flyGyro.CFrame = cam.CFrame
            if armsRaised then
                setSuperheroArms(character, false)
                armsRaised = false
            end
            local trail = speedTrails[character]
            if trail then
                trail.Enabled = false
            end
        end
    end)
end

----------------------------------------------------------------
-- Movementタブ: Fly行(歯車 + トグル) + スーパーヒーロー設定
----------------------------------------------------------------
local flyRow = Instance.new("Frame")
flyRow.Size = UDim2.new(1, 0, 0, 36)
flyRow.BackgroundTransparency = 1
flyRow.Parent = MovementPage

local flyGearBtn = Instance.new("TextButton")
flyGearBtn.Size = UDim2.new(0, 26, 0, 26)
flyGearBtn.Position = UDim2.new(0, 0, 0.5, -13)
flyGearBtn.BackgroundColor3 = Color3.fromRGB(50, 50, 55)
flyGearBtn.Text = "⚙"
flyGearBtn.TextColor3 = Color3.fromRGB(230, 230, 230)
flyGearBtn.Font = Enum.Font.GothamBold
flyGearBtn.TextSize = 16
flyGearBtn.Parent = flyRow

local flyGearBtnCorner = Instance.new("UICorner")
flyGearBtnCorner.CornerRadius = UDim.new(0, 6)
flyGearBtnCorner.Parent = flyGearBtn

local flyLabel = Instance.new("TextLabel")
flyLabel.Size = UDim2.new(1, -80, 1, 0)
flyLabel.Position = UDim2.new(0, 34, 0, 0)
flyLabel.BackgroundTransparency = 1
flyLabel.Text = "Fly (空を飛ぶ)"
flyLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
flyLabel.Font = Enum.Font.Gotham
flyLabel.TextSize = 14
flyLabel.TextXAlignment = Enum.TextXAlignment.Left
flyLabel.Parent = flyRow

local flySwitch = createToggleSwitch(44, false, function(state)
    if state then
        startFly()
    else
        stopFly()
    end
end)
flySwitch.Position = UDim2.new(1, -44, 0.5, -13)
flySwitch.Parent = flyRow

-- Fly詳細設定パネル(歯車クリックで開閉)
local flySettingsPanel = Instance.new("Frame")
flySettingsPanel.Size = UDim2.new(1, 0, 0, 0)
flySettingsPanel.BackgroundColor3 = Color3.fromRGB(24, 24, 28)
flySettingsPanel.BorderSizePixel = 0
flySettingsPanel.ClipsDescendants = true
flySettingsPanel.Visible = false
flySettingsPanel.Parent = MovementPage

local flyPanelCorner = Instance.new("UICorner")
flyPanelCorner.CornerRadius = UDim.new(0, 6)
flyPanelCorner.Parent = flySettingsPanel

local flyPanelPadding = Instance.new("UIPadding")
flyPanelPadding.PaddingLeft = UDim.new(0, 10)
flyPanelPadding.PaddingRight = UDim.new(0, 10)
flyPanelPadding.PaddingTop = UDim.new(0, 6)
flyPanelPadding.PaddingBottom = UDim.new(0, 6)
flyPanelPadding.Parent = flySettingsPanel

local superheroRow = Instance.new("Frame")
superheroRow.Size = UDim2.new(1, 0, 0, 30)
superheroRow.BackgroundTransparency = 1
superheroRow.Parent = flySettingsPanel

local superheroLabel = Instance.new("TextLabel")
superheroLabel.Size = UDim2.new(0.7, 0, 1, 0)
superheroLabel.BackgroundTransparency = 1
superheroLabel.Text = "スーパーヒーロー"
superheroLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
superheroLabel.Font = Enum.Font.Gotham
superheroLabel.TextSize = 13
superheroLabel.TextXAlignment = Enum.TextXAlignment.Left
superheroLabel.Parent = superheroRow

local superheroSwitch = createToggleSwitch(36, false, function(state)
    superheroMode = state
    if not state then
        -- OFFにした瞬間、上がっている腕とトレイルをすぐ元に戻す
        local character = LocalPlayer.Character
        if character then
            setSuperheroArms(character, false)
            local trail = speedTrails[character]
            if trail then
                trail.Enabled = false
            end
        end
    end
end)
superheroSwitch.Size = UDim2.new(0, 36, 0, 18)
superheroSwitch.Position = UDim2.new(1, -36, 0.5, -9)
superheroSwitch.Parent = superheroRow

local flyPanelOpen = false
flyGearBtn.MouseButton1Click:Connect(function()
    flyPanelOpen = not flyPanelOpen
    flySettingsPanel.Visible = true
    local targetHeight = flyPanelOpen and 40 or 0
    local tween = TweenService:Create(flySettingsPanel, TweenInfo.new(0.2), {Size = UDim2.new(1, 0, 0, targetHeight)})
    tween:Play()
    tween.Completed:Connect(function()
        if not flyPanelOpen then
            flySettingsPanel.Visible = false
        end
    end)
end)

----------------------------------------------------------------
-- Movementタブ: TP (好きな場所の座標を登録してテレポート)
----------------------------------------------------------------
local tpPosition = nil
local tpSelecting = false

local tpRow = Instance.new("Frame")
tpRow.Size = UDim2.new(1, 0, 0, 36)
tpRow.BackgroundTransparency = 1
tpRow.Parent = MovementPage

local tpGearBtn = Instance.new("TextButton")
tpGearBtn.Size = UDim2.new(0, 26, 0, 26)
tpGearBtn.Position = UDim2.new(0, 0, 0.5, -13)
tpGearBtn.BackgroundColor3 = Color3.fromRGB(50, 50, 55)
tpGearBtn.Text = "⚙"
tpGearBtn.TextColor3 = Color3.fromRGB(230, 230, 230)
tpGearBtn.Font = Enum.Font.GothamBold
tpGearBtn.TextSize = 16
tpGearBtn.Parent = tpRow

local tpGearBtnCorner = Instance.new("UICorner")
tpGearBtnCorner.CornerRadius = UDim.new(0, 6)
tpGearBtnCorner.Parent = tpGearBtn

local tpLabel = Instance.new("TextLabel")
tpLabel.Size = UDim2.new(1, -140, 1, 0)
tpLabel.Position = UDim2.new(0, 34, 0, 0)
tpLabel.BackgroundTransparency = 1
tpLabel.Text = "TP"
tpLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
tpLabel.Font = Enum.Font.Gotham
tpLabel.TextSize = 14
tpLabel.TextXAlignment = Enum.TextXAlignment.Left
tpLabel.Parent = tpRow

local tpSelectButton = Instance.new("TextButton")
tpSelectButton.Size = UDim2.new(0, 100, 0, 26)
tpSelectButton.Position = UDim2.new(1, -100, 0.5, -13)
tpSelectButton.BackgroundColor3 = Color3.fromRGB(70, 130, 230)
tpSelectButton.Text = "選択"
tpSelectButton.TextColor3 = Color3.fromRGB(255, 255, 255)
tpSelectButton.Font = Enum.Font.GothamBold
tpSelectButton.TextSize = 13
tpSelectButton.Parent = tpRow

local tpSelectButtonCorner = Instance.new("UICorner")
tpSelectButtonCorner.CornerRadius = UDim.new(0, 6)
tpSelectButtonCorner.Parent = tpSelectButton

-- TP詳細設定パネル(歯車クリックで開閉、座標を手動編集+TPボタン)
local tpSettingsPanel = Instance.new("Frame")
tpSettingsPanel.Size = UDim2.new(1, 0, 0, 0)
tpSettingsPanel.BackgroundColor3 = Color3.fromRGB(24, 24, 28)
tpSettingsPanel.BorderSizePixel = 0
tpSettingsPanel.ClipsDescendants = true
tpSettingsPanel.Visible = false
tpSettingsPanel.Parent = MovementPage

local tpPanelCorner = Instance.new("UICorner")
tpPanelCorner.CornerRadius = UDim.new(0, 6)
tpPanelCorner.Parent = tpSettingsPanel

local tpPanelPadding = Instance.new("UIPadding")
tpPanelPadding.PaddingLeft = UDim.new(0, 10)
tpPanelPadding.PaddingRight = UDim.new(0, 10)
tpPanelPadding.PaddingTop = UDim.new(0, 8)
tpPanelPadding.PaddingBottom = UDim.new(0, 8)
tpPanelPadding.Parent = tpSettingsPanel

local tpCoordLabel = Instance.new("TextLabel")
tpCoordLabel.Size = UDim2.new(1, 0, 0, 14)
tpCoordLabel.BackgroundTransparency = 1
tpCoordLabel.Text = "座標 (X / Y / Z)"
tpCoordLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
tpCoordLabel.Font = Enum.Font.Gotham
tpCoordLabel.TextSize = 12
tpCoordLabel.TextXAlignment = Enum.TextXAlignment.Left
tpCoordLabel.Parent = tpSettingsPanel

local function createTPCoordBox(posX, width)
    local box = Instance.new("TextBox")
    box.Size = UDim2.new(width, 0, 0, 24)
    box.Position = UDim2.new(posX, 0, 0, 18)
    box.BackgroundColor3 = Color3.fromRGB(45, 45, 50)
    box.Text = "0"
    box.TextColor3 = Color3.fromRGB(255, 255, 255)
    box.Font = Enum.Font.Gotham
    box.TextSize = 13
    box.ClearTextOnFocus = false
    box.Parent = tpSettingsPanel

    local corner = Instance.new("UICorner")
    corner.CornerRadius = UDim.new(0, 5)
    corner.Parent = box

    return box
end

local tpXBox = createTPCoordBox(0, 0.2)
local tpYBox = createTPCoordBox(0.22, 0.2)
local tpZBox = createTPCoordBox(0.44, 0.2)

local tpGoButton = Instance.new("TextButton")
tpGoButton.Size = UDim2.new(0.32, 0, 0, 24)
tpGoButton.Position = UDim2.new(0.68, 0, 0, 18)
tpGoButton.BackgroundColor3 = Color3.fromRGB(45, 160, 90)
tpGoButton.Text = "TP"
tpGoButton.TextColor3 = Color3.fromRGB(255, 255, 255)
tpGoButton.Font = Enum.Font.GothamBold
tpGoButton.TextSize = 13
tpGoButton.Parent = tpSettingsPanel

local tpGoButtonCorner = Instance.new("UICorner")
tpGoButtonCorner.CornerRadius = UDim.new(0, 5)
tpGoButtonCorner.Parent = tpGoButton

local function updateTPBoxes()
    if not tpPosition then return end
    tpXBox.Text = string.format("%.1f", tpPosition.X)
    tpYBox.Text = string.format("%.1f", tpPosition.Y)
    tpZBox.Text = string.format("%.1f", tpPosition.Z)
end

local function teleportToPosition(pos)
    local character = LocalPlayer.Character
    local root = character and character:FindFirstChild("HumanoidRootPart")
    if root and pos then
        root.CFrame = CFrame.new(pos + Vector3.new(0, 3, 0))
    end
end

tpGoButton.MouseButton1Click:Connect(function()
    local x = tonumber(tpXBox.Text)
    local y = tonumber(tpYBox.Text)
    local z = tonumber(tpZBox.Text)
    if not (x and y and z) then return end

    tpPosition = Vector3.new(x, y, z)
    teleportToPosition(tpPosition)
end)

local tpPanelOpen = false
tpGearBtn.MouseButton1Click:Connect(function()
    tpPanelOpen = not tpPanelOpen
    tpSettingsPanel.Visible = true
    local targetHeight = tpPanelOpen and 50 or 0
    local tween = TweenService:Create(tpSettingsPanel, TweenInfo.new(0.2), {Size = UDim2.new(1, 0, 0, targetHeight)})
    tween:Play()
    tween.Completed:Connect(function()
        if not tpPanelOpen then
            tpSettingsPanel.Visible = false
        end
    end)
end)

-- 選択ボタン: 押すと次にクリックした場所の座標を登録する
tpSelectButton.MouseButton1Click:Connect(function()
    tpSelecting = true
    tpSelectButton.Text = "クリック..."
end)

UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if not tpSelecting then return end
    if input.UserInputType ~= Enum.UserInputType.MouseButton1 and input.UserInputType ~= Enum.UserInputType.Touch then
        return
    end
    if gameProcessed then return end -- Hub自体やボタンをクリックした場合は無視

    tpSelecting = false
    tpSelectButton.Text = "選択"

    local hit = LocalMouse.Hit
    if hit then
        tpPosition = hit.Position
        updateTPBoxes()
    end
end)

----------------------------------------------------------------
-- Movementタブ: プレイヤーTP (ユーザー名 or 表示名を入力してそのプレイヤーへテレポート)
----------------------------------------------------------------
local playerTPContainer = Instance.new("Frame")
playerTPContainer.Size = UDim2.new(1, 0, 0, 40)
playerTPContainer.BackgroundTransparency = 1
playerTPContainer.Parent = MovementPage

local playerTPLabel = Instance.new("TextLabel")
playerTPLabel.Size = UDim2.new(1, 0, 0, 16)
playerTPLabel.BackgroundTransparency = 1
playerTPLabel.Text = "プレイヤーTP (ユーザー名 / 表示名)"
playerTPLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
playerTPLabel.Font = Enum.Font.Gotham
playerTPLabel.TextSize = 13
playerTPLabel.TextXAlignment = Enum.TextXAlignment.Left
playerTPLabel.Parent = playerTPContainer

local playerTPBox = Instance.new("TextBox")
playerTPBox.Size = UDim2.new(0.7, -6, 0, 24)
playerTPBox.Position = UDim2.new(0, 0, 0, 18)
playerTPBox.BackgroundColor3 = Color3.fromRGB(45, 45, 50)
playerTPBox.Text = ""
playerTPBox.PlaceholderText = "名前を入力"
playerTPBox.TextColor3 = Color3.fromRGB(255, 255, 255)
playerTPBox.Font = Enum.Font.Gotham
playerTPBox.TextSize = 13
playerTPBox.ClearTextOnFocus = false
playerTPBox.Parent = playerTPContainer

local playerTPBoxCorner = Instance.new("UICorner")
playerTPBoxCorner.CornerRadius = UDim.new(0, 5)
playerTPBoxCorner.Parent = playerTPBox

local playerTPGoButton = Instance.new("TextButton")
playerTPGoButton.Size = UDim2.new(0.3, -6, 0, 24)
playerTPGoButton.Position = UDim2.new(0.7, 6, 0, 18)
playerTPGoButton.BackgroundColor3 = Color3.fromRGB(45, 160, 90)
playerTPGoButton.Text = "TP"
playerTPGoButton.TextColor3 = Color3.fromRGB(255, 255, 255)
playerTPGoButton.Font = Enum.Font.GothamBold
playerTPGoButton.TextSize = 13
playerTPGoButton.Parent = playerTPContainer

local playerTPGoButtonCorner = Instance.new("UICorner")
playerTPGoButtonCorner.CornerRadius = UDim.new(0, 5)
playerTPGoButtonCorner.Parent = playerTPGoButton

local function findPlayerByName(query)
    if not query or query == "" then return nil end
    local lowerQuery = query:lower()

    -- 完全一致を優先(ユーザー名 → 表示名)
    for _, player in pairs(Players:GetPlayers()) do
        if player.Name:lower() == lowerQuery or player.DisplayName:lower() == lowerQuery then
            return player
        end
    end

    -- 部分一致(前方一致)
    for _, player in pairs(Players:GetPlayers()) do
        if player.Name:lower():sub(1, #lowerQuery) == lowerQuery
            or player.DisplayName:lower():sub(1, #lowerQuery) == lowerQuery then
            return player
        end
    end

    return nil
end

local function teleportToPlayer()
    local target = findPlayerByName(playerTPBox.Text)
    if not target then
        playerTPBox.PlaceholderText = "見つかりません"
        return
    end
    if target == LocalPlayer then return end

    local targetCharacter = target.Character
    local targetRoot = targetCharacter and targetCharacter:FindFirstChild("HumanoidRootPart")
    if targetRoot then
        teleportToPosition(targetRoot.Position)
    end
end

playerTPGoButton.MouseButton1Click:Connect(teleportToPlayer)
playerTPBox.FocusLost:Connect(function(enterPressed)
    if enterPressed then
        teleportToPlayer()
    end
end)

----------------------------------------------------------------
-- Movementタブ: Anti-Fall (落下ダメージ無効化)
-- 落下中に地面が近づいたら、1秒だけY方向の速度を止めて衝撃を和らげる
----------------------------------------------------------------
local antiFallEnabled = false
local antiFallCushioning = false
local antiFallConnection = nil

local antiFallRayParams = RaycastParams.new()
antiFallRayParams.FilterType = Enum.RaycastFilterType.Exclude

local ANTI_FALL_TRIGGER_DISTANCE = 12   -- 地面までこの距離以内で発動
local ANTI_FALL_VELOCITY_THRESHOLD = -60 -- この速度以上(下向き)で落下中なら対象
local ANTI_FALL_CUSHION_DURATION = 1    -- 秒

local function startAntiFall()
    antiFallEnabled = true
    antiFallConnection = RunService.Stepped:Connect(function()
        if antiFallCushioning then return end

        local character = LocalPlayer.Character
        local root = character and character:FindFirstChild("HumanoidRootPart")
        local humanoid = character and character:FindFirstChildOfClass("Humanoid")
        if not root or not humanoid then return end

        local velocity = root.AssemblyLinearVelocity
        if velocity.Y >= ANTI_FALL_VELOCITY_THRESHOLD then return end -- 十分な速度で落下していない

        antiFallRayParams.FilterDescendantsInstances = { character }
        local result = Workspace:Raycast(root.Position, Vector3.new(0, -ANTI_FALL_TRIGGER_DISTANCE, 0), antiFallRayParams)
        if not result then return end

        -- 地面が近く、かつ高速で落下中 → 1秒だけふわっと止める
        antiFallCushioning = true
        task.spawn(function()
            local endTime = os.clock() + ANTI_FALL_CUSHION_DURATION
            while os.clock() < endTime do
                if not antiFallEnabled then break end
                local char = LocalPlayer.Character
                local r = char and char:FindFirstChild("HumanoidRootPart")
                if not r then break end
                local v = r.AssemblyLinearVelocity
                r.AssemblyLinearVelocity = Vector3.new(v.X, 0, v.Z)
                task.wait()
            end
            antiFallCushioning = false
        end)
    end)
end

local function stopAntiFall()
    antiFallEnabled = false
    antiFallCushioning = false
    if antiFallConnection then
        antiFallConnection:Disconnect()
        antiFallConnection = nil
    end
end

createToggle(MovementPage, "Anti-Fall (落下ダメージ無効化)", false, function(state)
    if state then
        startAntiFall()
    else
        stopAntiFall()
    end
end)

----------------------------------------------------------------
-- Movementタブ: 嘘のラグ (10秒以内にランダムなタイミングで1秒だけカクつく)
----------------------------------------------------------------
local fakeLagEnabled = false
local fakeLagTask = nil

local function fakeLagLoop()
    while fakeLagEnabled do
        local waitTime = math.random() * 10 -- 0〜10秒のランダムな間隔
        task.wait(waitTime)
        if not fakeLagEnabled then break end

        local character = LocalPlayer.Character
        local root = character and character:FindFirstChild("HumanoidRootPart")
        if root then
            root.Anchored = true
            task.wait(1) -- 1秒間その場に固定(他人から見るとカクッと止まって見える)
            if root and root.Parent then
                root.Anchored = false
            end
        end
    end
end

createToggle(MovementPage, "嘘のラグ (Fake Lag)", false, function(state)
    fakeLagEnabled = state
    if state then
        fakeLagTask = task.spawn(fakeLagLoop)
    else
        if fakeLagTask then
            task.cancel(fakeLagTask)
            fakeLagTask = nil
        end
        local character = LocalPlayer.Character
        local root = character and character:FindFirstChild("HumanoidRootPart")
        if root then
            root.Anchored = false
        end
    end
end)

LocalPlayer.CharacterAdded:Connect(function()
    task.wait(0.3)
    applyToCharacter()
    if flying then
        stopFly()
    end
end)

----------------------------------------------------------------
-- Visualタブ: ESP (全員表示) + 歯車設定(Distance/Health)
----------------------------------------------------------------
local espEnabled = false
local espSettings = {
    ShowDistance = false,
    ShowHealth = false,
    ShowChat = false,
}
local chamsColor = Color3.fromRGB(255, 60, 60) -- ESPハイライトの色(Chams)
local CHAT_DISPLAY_DURATION = 10 -- チャット表示を残す秒数

local espData = {} -- [player] = {highlight, billboard, distanceLabel, healthLabel, chatBillboard, chatLabel, chatConnection, chatHideTask}

local function addESP(player)
    if player == LocalPlayer then return end
    if not player.Character then return end
    if espData[player] then return end

    local character = player.Character
    local head = character:FindFirstChild("Head") or character:FindFirstChild("HumanoidRootPart")

    local highlight = Instance.new("Highlight")
    highlight.FillColor = chamsColor
    highlight.OutlineColor = Color3.fromRGB(255, 255, 255)
    highlight.FillTransparency = 0.5
    highlight.OutlineTransparency = 0
    highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
    highlight.Parent = character

    local billboard = Instance.new("BillboardGui")
    billboard.Size = UDim2.new(0, 120, 0, 36)
    billboard.StudsOffset = Vector3.new(0, 1, 0)
    billboard.AlwaysOnTop = true
    billboard.Adornee = head
    billboard.Enabled = false
    billboard.Parent = character

    local nameLabel = Instance.new("TextLabel")
    nameLabel.Size = UDim2.new(1, 0, 0, 14)
    nameLabel.BackgroundTransparency = 1
    nameLabel.Text = player.Name
    nameLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
    nameLabel.Font = Enum.Font.GothamBold
    nameLabel.TextSize = 12
    nameLabel.Parent = billboard

    local distanceLabel = Instance.new("TextLabel")
    distanceLabel.Size = UDim2.new(1, 0, 0, 12)
    distanceLabel.Position = UDim2.new(0, 0, 0, 14)
    distanceLabel.BackgroundTransparency = 1
    distanceLabel.Text = ""
    distanceLabel.TextColor3 = Color3.fromRGB(255, 220, 100)
    distanceLabel.Font = Enum.Font.Gotham
    distanceLabel.TextSize = 11
    distanceLabel.Visible = false
    distanceLabel.Parent = billboard

    local healthLabel = Instance.new("TextLabel")
    healthLabel.Size = UDim2.new(1, 0, 0, 12)
    healthLabel.Position = UDim2.new(0, 0, 0, 24)
    healthLabel.BackgroundTransparency = 1
    healthLabel.Text = ""
    healthLabel.TextColor3 = Color3.fromRGB(100, 255, 120)
    healthLabel.Font = Enum.Font.Gotham
    healthLabel.TextSize = 11
    healthLabel.Visible = false
    healthLabel.Parent = billboard

    -- チャット表示用の吹き出し(ESP情報タグの上に表示)
    local chatBillboard = Instance.new("BillboardGui")
    chatBillboard.Size = UDim2.new(0, 180, 0, 50)
    chatBillboard.StudsOffset = Vector3.new(0, 2.7, 0)
    chatBillboard.AlwaysOnTop = true
    chatBillboard.Adornee = head
    chatBillboard.Enabled = false
    chatBillboard.Parent = character

    local chatBg = Instance.new("Frame")
    chatBg.Size = UDim2.new(1, 0, 1, 0)
    chatBg.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
    chatBg.BackgroundTransparency = 0.35
    chatBg.BorderSizePixel = 0
    chatBg.Parent = chatBillboard

    local chatBgCorner = Instance.new("UICorner")
    chatBgCorner.CornerRadius = UDim.new(0, 8)
    chatBgCorner.Parent = chatBg

    local chatLabel = Instance.new("TextLabel")
    chatLabel.Size = UDim2.new(1, -10, 1, -10)
    chatLabel.Position = UDim2.new(0, 5, 0, 5)
    chatLabel.BackgroundTransparency = 1
    chatLabel.Text = ""
    chatLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
    chatLabel.Font = Enum.Font.Gotham
    chatLabel.TextSize = 13
    chatLabel.TextWrapped = true
    chatLabel.TextYAlignment = Enum.TextYAlignment.Center
    chatLabel.Parent = chatBg

    local chatHideTask = nil

    local chatConnection = player.Chatted:Connect(function(message)
        local data = espData[player]
        if not data then return end
        if not espSettings.ShowChat then return end

        data.chatLabel.Text = message
        data.chatBillboard.Enabled = true

        if data.chatHideTask then
            task.cancel(data.chatHideTask)
        end
        data.chatHideTask = task.delay(CHAT_DISPLAY_DURATION, function()
            data.chatBillboard.Enabled = false
            data.chatHideTask = nil
        end)
    end)

    espData[player] = {
        highlight = highlight,
        billboard = billboard,
        distanceLabel = distanceLabel,
        healthLabel = healthLabel,
        chatBillboard = chatBillboard,
        chatLabel = chatLabel,
        chatConnection = chatConnection,
        chatHideTask = nil,
    }
end

local function removeESP(player)
    local data = espData[player]
    if not data then return end
    if data.highlight then data.highlight:Destroy() end
    if data.billboard then data.billboard:Destroy() end
    if data.chatBillboard then data.chatBillboard:Destroy() end
    if data.chatConnection then data.chatConnection:Disconnect() end
    if data.chatHideTask then task.cancel(data.chatHideTask) end
    espData[player] = nil
end

local function refreshESP()
    if espEnabled then
        for _, player in pairs(Players:GetPlayers()) do
            addESP(player)
        end
    else
        for player, _ in pairs(espData) do
            removeESP(player)
        end
    end
end

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
        if espEnabled then
            task.wait(0.5)
            addESP(player)
        end
    end)
end)

Players.PlayerRemoving:Connect(function(player)
    removeESP(player)
end)

-- 毎フレーム更新: 距離 / 体力 / トレーサーライン
RunService.RenderStepped:Connect(function()
    if not espEnabled then return end
    local cam = Workspace.CurrentCamera

    for player, data in pairs(espData) do
        local character = player.Character
        if not character or not character:FindFirstChild("HumanoidRootPart") then
            data.billboard.Enabled = false
            continue
        end

        local root = character.HumanoidRootPart
        local humanoid = character:FindFirstChildOfClass("Humanoid")

        -- Distance / Health billboard
        local showBillboard = espSettings.ShowDistance or espSettings.ShowHealth
        data.billboard.Enabled = showBillboard
        if espSettings.ShowDistance then
            local dist = (cam.CFrame.Position - root.Position).Magnitude
            data.distanceLabel.Text = string.format("%.0f スタッド", dist)
            data.distanceLabel.Visible = true
        else
            data.distanceLabel.Visible = false
        end
        if espSettings.ShowHealth and humanoid then
            data.healthLabel.Text = string.format("体力: %d/%d", math.floor(humanoid.Health), math.floor(humanoid.MaxHealth))
            data.healthLabel.Visible = true
        else
            data.healthLabel.Visible = false
        end
    end
end)

-- ESP行(歯車 + トグル)を構築
local espRow = Instance.new("Frame")
espRow.Size = UDim2.new(1, 0, 0, 36)
espRow.BackgroundTransparency = 1
espRow.Parent = VisualPage

local gearBtn = Instance.new("TextButton")
gearBtn.Size = UDim2.new(0, 26, 0, 26)
gearBtn.Position = UDim2.new(0, 0, 0.5, -13)
gearBtn.BackgroundColor3 = Color3.fromRGB(50, 50, 55)
gearBtn.Text = "⚙"
gearBtn.TextColor3 = Color3.fromRGB(230, 230, 230)
gearBtn.Font = Enum.Font.GothamBold
gearBtn.TextSize = 16
gearBtn.Parent = espRow

local gearCorner = Instance.new("UICorner")
gearCorner.CornerRadius = UDim.new(0, 6)
gearCorner.Parent = gearBtn

local espLabel = Instance.new("TextLabel")
espLabel.Size = UDim2.new(1, -80, 1, 0)
espLabel.Position = UDim2.new(0, 34, 0, 0)
espLabel.BackgroundTransparency = 1
espLabel.Text = "ESP (全員表示)"
espLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
espLabel.Font = Enum.Font.Gotham
espLabel.TextSize = 14
espLabel.TextXAlignment = Enum.TextXAlignment.Left
espLabel.Parent = espRow

local espSwitch = createToggleSwitch(44, false, function(state)
    espEnabled = state
    refreshESP()
end)
espSwitch.Position = UDim2.new(1, -44, 0.5, -11)
espSwitch.Parent = espRow

-- ESP詳細設定パネル(歯車クリックで開閉)
local espSettingsPanel = Instance.new("Frame")
espSettingsPanel.Size = UDim2.new(1, 0, 0, 0)
espSettingsPanel.BackgroundColor3 = Color3.fromRGB(24, 24, 28)
espSettingsPanel.BorderSizePixel = 0
espSettingsPanel.ClipsDescendants = true
espSettingsPanel.Visible = false
espSettingsPanel.Parent = VisualPage

local espPanelCorner = Instance.new("UICorner")
espPanelCorner.CornerRadius = UDim.new(0, 6)
espPanelCorner.Parent = espSettingsPanel

local espPanelPadding = Instance.new("UIPadding")
espPanelPadding.PaddingLeft = UDim.new(0, 10)
espPanelPadding.PaddingRight = UDim.new(0, 10)
espPanelPadding.PaddingTop = UDim.new(0, 6)
espPanelPadding.PaddingBottom = UDim.new(0, 6)
espPanelPadding.Parent = espSettingsPanel

local espPanelLayout = Instance.new("UIListLayout")
espPanelLayout.Padding = UDim.new(0, 4)
espPanelLayout.SortOrder = Enum.SortOrder.LayoutOrder
espPanelLayout.Parent = espSettingsPanel

local function addEspSettingToggle(labelText, key, onToggle)
    local row = Instance.new("Frame")
    row.Size = UDim2.new(1, 0, 0, 30)
    row.BackgroundTransparency = 1
    row.Parent = espSettingsPanel

    local label = Instance.new("TextLabel")
    label.Size = UDim2.new(0.7, 0, 1, 0)
    label.BackgroundTransparency = 1
    label.Text = labelText
    label.TextColor3 = Color3.fromRGB(200, 200, 200)
    label.Font = Enum.Font.Gotham
    label.TextSize = 13
    label.TextXAlignment = Enum.TextXAlignment.Left
    label.Parent = row

    local sw = createToggleSwitch(36, espSettings[key], function(state)
        espSettings[key] = state
        if onToggle then
            onToggle(state)
        end
    end)
    sw.Size = UDim2.new(0, 36, 0, 18)
    sw.Position = UDim2.new(1, -36, 0.5, -9)
    sw.Parent = row
end

addEspSettingToggle("Distance (距離)", "ShowDistance")
addEspSettingToggle("Health (体力)", "ShowHealth")
addEspSettingToggle("Chat (チャット表示)", "ShowChat", function(state)
    if not state then
        -- OFFにした瞬間、表示中の吹き出しを一括で隠す
        for _, data in pairs(espData) do
            if data.chatHideTask then
                task.cancel(data.chatHideTask)
                data.chatHideTask = nil
            end
            if data.chatBillboard then
                data.chatBillboard.Enabled = false
            end
        end
    end
end)

----------------------------------------------------------------
-- Chams色変更 (ESPハイライトの色をRGBで自由に指定) ※歯車パネルの中に配置
----------------------------------------------------------------
local chamsRow = Instance.new("Frame")
chamsRow.Size = UDim2.new(1, 0, 0, 44)
chamsRow.BackgroundTransparency = 1
chamsRow.Parent = espSettingsPanel

local chamsLabel = Instance.new("TextLabel")
chamsLabel.Size = UDim2.new(1, 0, 0, 16)
chamsLabel.BackgroundTransparency = 1
chamsLabel.Text = "ハイライト色 (R / G / B)"
chamsLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
chamsLabel.Font = Enum.Font.Gotham
chamsLabel.TextSize = 12
chamsLabel.TextXAlignment = Enum.TextXAlignment.Left
chamsLabel.Parent = chamsRow

local function createRGBBox(parent, posX, defaultValue)
    local box = Instance.new("TextBox")
    box.Size = UDim2.new(0.22, 0, 0, 24)
    box.Position = UDim2.new(posX, 0, 0, 18)
    box.BackgroundColor3 = Color3.fromRGB(45, 45, 50)
    box.Text = tostring(defaultValue)
    box.TextColor3 = Color3.fromRGB(255, 255, 255)
    box.Font = Enum.Font.Gotham
    box.TextSize = 13
    box.ClearTextOnFocus = false
    box.Parent = parent

    local corner = Instance.new("UICorner")
    corner.CornerRadius = UDim.new(0, 5)
    corner.Parent = box

    return box
end

local chamsRBox = createRGBBox(chamsRow, 0, 255)
local chamsGBox = createRGBBox(chamsRow, 0.25, 60)
local chamsBBox = createRGBBox(chamsRow, 0.5, 60)

local chamsApplyButton = Instance.new("TextButton")
chamsApplyButton.Size = UDim2.new(0.24, 0, 0, 24)
chamsApplyButton.Position = UDim2.new(0.76, 0, 0, 18)
chamsApplyButton.BackgroundColor3 = Color3.fromRGB(45, 160, 90)
chamsApplyButton.Text = "適用"
chamsApplyButton.TextColor3 = Color3.fromRGB(255, 255, 255)
chamsApplyButton.Font = Enum.Font.GothamBold
chamsApplyButton.TextSize = 13
chamsApplyButton.Parent = chamsRow

local chamsApplyCorner = Instance.new("UICorner")
chamsApplyCorner.CornerRadius = UDim.new(0, 5)
chamsApplyCorner.Parent = chamsApplyButton

chamsApplyButton.MouseButton1Click:Connect(function()
    local r = tonumber(chamsRBox.Text)
    local g = tonumber(chamsGBox.Text)
    local b = tonumber(chamsBBox.Text)
    if not (r and g and b) then return end

    r = math.clamp(r, 0, 255)
    g = math.clamp(g, 0, 255)
    b = math.clamp(b, 0, 255)
    chamsRBox.Text = tostring(r)
    chamsGBox.Text = tostring(g)
    chamsBBox.Text = tostring(b)

    chamsColor = Color3.fromRGB(r, g, b)

    -- 既に表示中のESPハイライトにも即反映
    for _, data in pairs(espData) do
        if data.highlight then
            data.highlight.FillColor = chamsColor
        end
    end
end)

local panelOpen = false
gearBtn.MouseButton1Click:Connect(function()
    panelOpen = not panelOpen
    espSettingsPanel.Visible = true
    local targetHeight = panelOpen and 152 or 0
    local tween = TweenService:Create(espSettingsPanel, TweenInfo.new(0.2), {Size = UDim2.new(1, 0, 0, targetHeight)})
    tween:Play()
    tween.Completed:Connect(function()
        if not panelOpen then
            espSettingsPanel.Visible = false
        end
    end)
end)

----------------------------------------------------------------
-- Visualタブ: FOV変更
----------------------------------------------------------------
-- Robloxの標準カメラスクリプトが毎フレームFieldOfViewを既定値に戻してしまうため、
-- こちらも毎フレーム強制的に上書きして確実に反映させる
local desiredFOV = nil

RunService.RenderStepped:Connect(function()
    if desiredFOV then
        local cam = Workspace.CurrentCamera
        if cam then
            cam.FieldOfView = desiredFOV
        end
    end
end)

createNumberInput(VisualPage, "視野角", 70, 1, 120, function(value)
    desiredFOV = value
    local cam = Workspace.CurrentCamera
    if cam then
        cam.FieldOfView = value
    end
end)

----------------------------------------------------------------
-- Visualタブ: Fullbright (影を消して常に明るく)
----------------------------------------------------------------
local fullbrightEnabled = false
local savedLighting = nil

local function applyFullbright(state)
    if state then
        savedLighting = {
            Brightness = Lighting.Brightness,
            ClockTime = Lighting.ClockTime,
            GlobalShadows = Lighting.GlobalShadows,
            OutdoorAmbient = Lighting.OutdoorAmbient,
            Ambient = Lighting.Ambient,
        }
        Lighting.Brightness = 2
        Lighting.ClockTime = 14
        Lighting.GlobalShadows = false
        Lighting.OutdoorAmbient = Color3.fromRGB(180, 180, 180)
        Lighting.Ambient = Color3.fromRGB(180, 180, 180)
    else
        if savedLighting then
            Lighting.Brightness = savedLighting.Brightness
            Lighting.ClockTime = savedLighting.ClockTime
            Lighting.GlobalShadows = savedLighting.GlobalShadows
            Lighting.OutdoorAmbient = savedLighting.OutdoorAmbient
            Lighting.Ambient = savedLighting.Ambient
            savedLighting = nil
        end
    end
end

createToggle(VisualPage, "常時明るく (Fullbright)", false, function(state)
    fullbrightEnabled = state
    applyFullbright(state)
end)

----------------------------------------------------------------
-- Visualタブ: No Fog (霧を消す)
----------------------------------------------------------------
local noFogEnabled = false
local savedFog = nil

local function applyNoFog(state)
    if state then
        savedFog = {
            FogStart = Lighting.FogStart,
            FogEnd = Lighting.FogEnd,
        }
        Lighting.FogStart = 0
        Lighting.FogEnd = 100000
    else
        if savedFog then
            Lighting.FogStart = savedFog.FogStart
            Lighting.FogEnd = savedFog.FogEnd
            savedFog = nil
        end
    end
end

createToggle(VisualPage, "No Fog (霧を消す)", false, function(state)
    noFogEnabled = state
    applyNoFog(state)
end)

----------------------------------------------------------------
-- Visualタブ: フリーカメラ (キャラクターから離れてカメラだけ自由に動かす)
----------------------------------------------------------------
local freeCamEnabled = false
local freeCamConnection = nil
local freeCamCFrame = nil
local freeCamRightMouseDown = false

local FREE_CAM_SPEED = 60
local FREE_CAM_SENSITIVITY = 0.25

local function setCharacterAnchored(anchored)
    local character = LocalPlayer.Character
    if not character then return end
    for _, part in pairs(character:GetDescendants()) do
        if part:IsA("BasePart") then
            part.Anchored = anchored
        end
    end
end

-- 右クリックを押している間だけマウスをロックして視点回転できるようにする(通常のRoblox操作と同じ)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if not freeCamEnabled then return end
    if input.UserInputType == Enum.UserInputType.MouseButton2 then
        freeCamRightMouseDown = true
        UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
    end
end)

UserInputService.InputEnded:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton2 then
        freeCamRightMouseDown = false
        if freeCamEnabled then
            UserInputService.MouseBehavior = Enum.MouseBehavior.Default
        end
    end
end)

local function startFreeCam()
    freeCamEnabled = true
    local cam = Workspace.CurrentCamera
    freeCamCFrame = cam.CFrame
    cam.CameraType = Enum.CameraType.Scriptable
    UserInputService.MouseBehavior = Enum.MouseBehavior.Default -- 普段はマウス解放(Hubのボタンも押せる)
    setCharacterAnchored(true)

    freeCamConnection = RunService.RenderStepped:Connect(function(dt)
        local currentCam = Workspace.CurrentCamera
        if not currentCam then return end

        if freeCamRightMouseDown then
            local delta = UserInputService:GetMouseDelta()
            local yaw = -delta.X * FREE_CAM_SENSITIVITY * dt
            local pitch = -delta.Y * FREE_CAM_SENSITIVITY * dt

            freeCamCFrame = freeCamCFrame * CFrame.Angles(0, yaw, 0)
            freeCamCFrame = freeCamCFrame * CFrame.Angles(pitch, 0, 0)
        end

        local moveVector = Vector3.new()
        if UserInputService:IsKeyDown(Enum.KeyCode.W) then
            moveVector = moveVector + freeCamCFrame.LookVector
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.S) then
            moveVector = moveVector - freeCamCFrame.LookVector
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.A) then
            moveVector = moveVector - freeCamCFrame.RightVector
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.D) then
            moveVector = moveVector + freeCamCFrame.RightVector
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.Space) then
            moveVector = moveVector + Vector3.new(0, 1, 0)
        end
        if UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) then
            moveVector = moveVector - Vector3.new(0, 1, 0)
        end

        if moveVector.Magnitude > 0 then
            freeCamCFrame = freeCamCFrame + moveVector.Unit * FREE_CAM_SPEED * dt
        end

        currentCam.CFrame = freeCamCFrame
    end)
end

local function stopFreeCam()
    freeCamEnabled = false
    freeCamRightMouseDown = false
    if freeCamConnection then
        freeCamConnection:Disconnect()
        freeCamConnection = nil
    end
    UserInputService.MouseBehavior = Enum.MouseBehavior.Default
    local cam = Workspace.CurrentCamera
    if cam then
        cam.CameraType = Enum.CameraType.Custom
    end
    setCharacterAnchored(false)
end

createToggle(VisualPage, "フリーカメラ", false, function(state)
    if state then
        startFreeCam()
    else
        stopFreeCam()
    end
end)

----------------------------------------------------------------
-- Visualタブ: バー等 (HPバー / スピードバー / 高度 / FPS / Ping)
----------------------------------------------------------------
local hudEnabled = false
local barSettings = {
    ShowHP = true,
    ShowSpeed = true,
    ShowAltitude = true,
    ShowFPS = true,
    ShowPing = true,
}

local HudFrame = Instance.new("Frame")
HudFrame.Name = "HudFrame"
HudFrame.Size = UDim2.new(0, 160, 0, 158)
HudFrame.Position = UDim2.new(1, -176, 0, 16)
HudFrame.BackgroundColor3 = Color3.fromRGB(15, 15, 18)
HudFrame.BackgroundTransparency = 0.1
HudFrame.BorderSizePixel = 0
HudFrame.Visible = false
HudFrame.Parent = ScreenGui

local hudCorner = Instance.new("UICorner")
hudCorner.CornerRadius = UDim.new(0, 8)
hudCorner.Parent = HudFrame

-- ドラッグ用の持ち手(スマホでも動かしやすいように専用バーを用意)
local hudDragHandle = Instance.new("Frame")
hudDragHandle.Size = UDim2.new(1, 0, 0, 18)
hudDragHandle.BackgroundColor3 = Color3.fromRGB(24, 24, 28)
hudDragHandle.BorderSizePixel = 0
hudDragHandle.Parent = HudFrame

local hudDragHandleCorner = Instance.new("UICorner")
hudDragHandleCorner.CornerRadius = UDim.new(0, 8)
hudDragHandleCorner.Parent = hudDragHandle

local hudDragLabel = Instance.new("TextLabel")
hudDragLabel.Size = UDim2.new(1, 0, 1, 0)
hudDragLabel.BackgroundTransparency = 1
hudDragLabel.Text = "⠿"
hudDragLabel.TextColor3 = Color3.fromRGB(150, 150, 155)
hudDragLabel.Font = Enum.Font.GothamBold
hudDragLabel.TextSize = 12
hudDragLabel.Parent = hudDragHandle

makeDraggable(HudFrame, hudDragHandle)

local hudContent = Instance.new("Frame")
hudContent.Size = UDim2.new(1, 0, 1, -18)
hudContent.Position = UDim2.new(0, 0, 0, 18)
hudContent.BackgroundTransparency = 1
hudContent.Parent = HudFrame

local hudPadding = Instance.new("UIPadding")
hudPadding.PaddingLeft = UDim.new(0, 8)
hudPadding.PaddingRight = UDim.new(0, 8)
hudPadding.PaddingTop = UDim.new(0, 6)
hudPadding.PaddingBottom = UDim.new(0, 6)
hudPadding.Parent = hudContent

local hudLayout = Instance.new("UIListLayout")
hudLayout.Padding = UDim.new(0, 6)
hudLayout.SortOrder = Enum.SortOrder.LayoutOrder
hudLayout.Parent = hudContent

-- 共通: ラベル+バーのセットを作る
local function createHudBar(labelPrefix, barColor)
    local container = Instance.new("Frame")
    container.Size = UDim2.new(1, 0, 0, 26)
    container.BackgroundTransparency = 1
    container.Parent = hudContent

    local label = Instance.new("TextLabel")
    label.Size = UDim2.new(1, 0, 0, 12)
    label.BackgroundTransparency = 1
    label.Text = labelPrefix .. ": --"
    label.TextColor3 = Color3.fromRGB(220, 220, 220)
    label.Font = Enum.Font.Gotham
    label.TextSize = 11
    label.TextXAlignment = Enum.TextXAlignment.Left
    label.Parent = container

    local track = Instance.new("Frame")
    track.Size = UDim2.new(1, 0, 0, 8)
    track.Position = UDim2.new(0, 0, 0, 16)
    track.BackgroundColor3 = Color3.fromRGB(50, 50, 55)
    track.BorderSizePixel = 0
    track.Parent = container

    local trackCorner = Instance.new("UICorner")
    trackCorner.CornerRadius = UDim.new(1, 0)
    trackCorner.Parent = track

    local fill = Instance.new("Frame")
    fill.Size = UDim2.new(0, 0, 1, 0)
    fill.BackgroundColor3 = barColor
    fill.BorderSizePixel = 0
    fill.Parent = track

    local fillCorner = Instance.new("UICorner")
    fillCorner.CornerRadius = UDim.new(1, 0)
    fillCorner.Parent = fill

    return container, label, fill
end

local hpContainer, healthBarLabel, healthBarFill = createHudBar("HP", Color3.fromRGB(90, 220, 120))
local speedContainer, speedBarLabel, speedBarFill = createHudBar("Speed", Color3.fromRGB(90, 170, 255))
local altitudeContainer, altitudeBarLabel, altitudeBarFill = createHudBar("高度", Color3.fromRGB(230, 190, 90))

-- FPS
local fpsLabel = Instance.new("TextLabel")
fpsLabel.Size = UDim2.new(1, 0, 0, 14)
fpsLabel.BackgroundTransparency = 1
fpsLabel.Text = "FPS: --"
fpsLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
fpsLabel.Font = Enum.Font.Gotham
fpsLabel.TextSize = 12
fpsLabel.TextXAlignment = Enum.TextXAlignment.Left
fpsLabel.Parent = hudContent

-- Ping
local pingLabel = Instance.new("TextLabel")
pingLabel.Size = UDim2.new(1, 0, 0, 14)
pingLabel.BackgroundTransparency = 1
pingLabel.Text = "Ping: -- ms"
pingLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
pingLabel.Font = Enum.Font.Gotham
pingLabel.TextSize = 12
pingLabel.TextXAlignment = Enum.TextXAlignment.Left
pingLabel.Parent = hudContent

----------------------------------------------------------------
-- バー等の行(歯車 + トグル) + 詳細設定パネル
----------------------------------------------------------------
local barsRow = Instance.new("Frame")
barsRow.Size = UDim2.new(1, 0, 0, 36)
barsRow.BackgroundTransparency = 1
barsRow.Parent = VisualPage

local barsGearBtn = Instance.new("TextButton")
barsGearBtn.Size = UDim2.new(0, 26, 0, 26)
barsGearBtn.Position = UDim2.new(0, 0, 0.5, -13)
barsGearBtn.BackgroundColor3 = Color3.fromRGB(50, 50, 55)
barsGearBtn.Text = "⚙"
barsGearBtn.TextColor3 = Color3.fromRGB(230, 230, 230)
barsGearBtn.Font = Enum.Font.GothamBold
barsGearBtn.TextSize = 16
barsGearBtn.Parent = barsRow

local barsGearBtnCorner = Instance.new("UICorner")
barsGearBtnCorner.CornerRadius = UDim.new(0, 6)
barsGearBtnCorner.Parent = barsGearBtn

local barsLabel = Instance.new("TextLabel")
barsLabel.Size = UDim2.new(1, -80, 1, 0)
barsLabel.Position = UDim2.new(0, 34, 0, 0)
barsLabel.BackgroundTransparency = 1
barsLabel.Text = "バー等"
barsLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
barsLabel.Font = Enum.Font.Gotham
barsLabel.TextSize = 14
barsLabel.TextXAlignment = Enum.TextXAlignment.Left
barsLabel.Parent = barsRow

local barsSwitch = createToggleSwitch(44, false, function(state)
    hudEnabled = state
    HudFrame.Visible = state
end)
barsSwitch.Position = UDim2.new(1, -44, 0.5, -13)
barsSwitch.Parent = barsRow

local barsSettingsPanel = Instance.new("Frame")
barsSettingsPanel.Size = UDim2.new(1, 0, 0, 0)
barsSettingsPanel.BackgroundColor3 = Color3.fromRGB(24, 24, 28)
barsSettingsPanel.BorderSizePixel = 0
barsSettingsPanel.ClipsDescendants = true
barsSettingsPanel.Visible = false
barsSettingsPanel.Parent = VisualPage

local barsPanelCorner = Instance.new("UICorner")
barsPanelCorner.CornerRadius = UDim.new(0, 6)
barsPanelCorner.Parent = barsSettingsPanel

local barsPanelPadding = Instance.new("UIPadding")
barsPanelPadding.PaddingLeft = UDim.new(0, 10)
barsPanelPadding.PaddingRight = UDim.new(0, 10)
barsPanelPadding.PaddingTop = UDim.new(0, 6)
barsPanelPadding.PaddingBottom = UDim.new(0, 6)
barsPanelPadding.Parent = barsSettingsPanel

local barsPanelLayout = Instance.new("UIListLayout")
barsPanelLayout.Padding = UDim.new(0, 4)
barsPanelLayout.SortOrder = Enum.SortOrder.LayoutOrder
barsPanelLayout.Parent = barsSettingsPanel

local function addBarSettingToggle(labelText, key, container)
    local row = Instance.new("Frame")
    row.Size = UDim2.new(1, 0, 0, 26)
    row.BackgroundTransparency = 1
    row.Parent = barsSettingsPanel

    local label = Instance.new("TextLabel")
    label.Size = UDim2.new(0.7, 0, 1, 0)
    label.BackgroundTransparency = 1
    label.Text = labelText
    label.TextColor3 = Color3.fromRGB(200, 200, 200)
    label.Font = Enum.Font.Gotham
    label.TextSize = 13
    label.TextXAlignment = Enum.TextXAlignment.Left
    label.Parent = row

    local sw = createToggleSwitch(36, barSettings[key], function(state)
        barSettings[key] = state
        container.Visible = state
    end)
    sw.Size = UDim2.new(0, 36, 0, 18)
    sw.Position = UDim2.new(1, -36, 0.5, -9)
    sw.Parent = row
end

addBarSettingToggle("HPバー", "ShowHP", hpContainer)
addBarSettingToggle("スピードバー", "ShowSpeed", speedContainer)
addBarSettingToggle("高度", "ShowAltitude", altitudeContainer)
addBarSettingToggle("FPS", "ShowFPS", fpsLabel)
addBarSettingToggle("Ping", "ShowPing", pingLabel)

local barsPanelOpen = false
barsGearBtn.MouseButton1Click:Connect(function()
    barsPanelOpen = not barsPanelOpen
    barsSettingsPanel.Visible = true
    local targetHeight = barsPanelOpen and 150 or 0
    local tween = TweenService:Create(barsSettingsPanel, TweenInfo.new(0.2), {Size = UDim2.new(1, 0, 0, targetHeight)})
    tween:Play()
    tween.Completed:Connect(function()
        if not barsPanelOpen then
            barsSettingsPanel.Visible = false
        end
    end)
end)

----------------------------------------------------------------
-- 更新ループ
----------------------------------------------------------------
local NetworkStats = game:GetService("Stats").Network
local fpsFrameCount = 0
local fpsTimer = 0

local altitudeRayParams = RaycastParams.new()
altitudeRayParams.FilterType = Enum.RaycastFilterType.Exclude

RunService.RenderStepped:Connect(function(dt)
    if not hudEnabled then return end

    -- FPS計算(0.5秒ごとに更新)
    if barSettings.ShowFPS then
        fpsFrameCount = fpsFrameCount + 1
        fpsTimer = fpsTimer + dt
        if fpsTimer >= 0.5 then
            local fps = math.floor(fpsFrameCount / fpsTimer)
            fpsLabel.Text = "FPS: " .. fps
            fpsFrameCount = 0
            fpsTimer = 0
        end
    end

    local character = LocalPlayer.Character
    local humanoid = character and character:FindFirstChildOfClass("Humanoid")
    local root = character and character:FindFirstChild("HumanoidRootPart")

    -- HP
    if barSettings.ShowHP and humanoid then
        healthBarLabel.Text = string.format("HP: %d / %d", math.floor(humanoid.Health), math.floor(humanoid.MaxHealth))
        local pct = humanoid.MaxHealth > 0 and (humanoid.Health / humanoid.MaxHealth) or 0
        healthBarFill.Size = UDim2.new(math.clamp(pct, 0, 1), 0, 1, 0)
    end

    -- Speed(HumanoidRootPartの実際の速度)
    if barSettings.ShowSpeed and root then
        local speed = root.AssemblyLinearVelocity.Magnitude
        speedBarLabel.Text = string.format("Speed: %d", math.floor(speed))
        local pct = math.clamp(speed / 200, 0, 1) -- 200studs/sを目安に満タン
        speedBarFill.Size = UDim2.new(pct, 0, 1, 0)
    end

    -- 高度(地面までの距離をレイキャストで測定)
    if barSettings.ShowAltitude and root and character then
        altitudeRayParams.FilterDescendantsInstances = { character }
        local rayResult = Workspace:Raycast(root.Position, Vector3.new(0, -1000, 0), altitudeRayParams)
        local altitude = rayResult and rayResult.Distance or 0
        altitudeBarLabel.Text = string.format("高度: %d studs", math.floor(altitude))
        local pct = math.clamp(altitude / 300, 0, 1) -- 300studsを目安に満タン
        altitudeBarFill.Size = UDim2.new(pct, 0, 1, 0)
    end

    -- Ping
    if barSettings.ShowPing then
        local success, pingValue = pcall(function()
            return NetworkStats.ServerStatsItem["Data Ping"]:GetValue()
        end)
        if success and pingValue then
            pingLabel.Text = string.format("Ping: %d ms", math.floor(pingValue))
        end
    end
end)

----------------------------------------------------------------
-- メモ帳タブ: サーバー(DataStore)に保存され、抜けても再度読み込まれる
----------------------------------------------------------------
local memoStatusLabel = Instance.new("TextLabel")
memoStatusLabel.Size = UDim2.new(1, 0, 0, 16)
memoStatusLabel.BackgroundTransparency = 1
memoStatusLabel.Text = "※ このプレイ中のみ保持されます(抜けると消えます)"
memoStatusLabel.TextColor3 = Color3.fromRGB(150, 150, 155)
memoStatusLabel.Font = Enum.Font.Gotham
memoStatusLabel.TextSize = 11
memoStatusLabel.TextXAlignment = Enum.TextXAlignment.Left
memoStatusLabel.Parent = HelperPage

local memoBox = Instance.new("TextBox")
memoBox.Size = UDim2.new(1, 0, 0, 280)
memoBox.BackgroundColor3 = Color3.fromRGB(20, 20, 24)
memoBox.Text = ""
memoBox.PlaceholderText = "ここにメモを書く..."
memoBox.TextColor3 = Color3.fromRGB(230, 230, 230)
memoBox.Font = Enum.Font.Gotham
memoBox.TextSize = 14
memoBox.TextXAlignment = Enum.TextXAlignment.Left
memoBox.TextYAlignment = Enum.TextYAlignment.Top
memoBox.TextWrapped = true
memoBox.MultiLine = true
memoBox.ClearTextOnFocus = false
memoBox.Parent = HelperPage

local memoBoxCorner = Instance.new("UICorner")
memoBoxCorner.CornerRadius = UDim.new(0, 6)
memoBoxCorner.Parent = memoBox

local memoBoxPadding = Instance.new("UIPadding")
memoBoxPadding.PaddingLeft = UDim.new(0, 8)
memoBoxPadding.PaddingRight = UDim.new(0, 8)
memoBoxPadding.PaddingTop = UDim.new(0, 8)
memoBoxPadding.PaddingBottom = UDim.new(0, 8)
memoBoxPadding.Parent = memoBox

-- 特に何かする必要はなく、TextBoxの中身がそのままメモとして保持される
-- (LocalScriptの実行中だけメモリ上に残る。ゲームを抜けると消える)

-- 初期キャラクターへの適用
if LocalPlayer.Character then
    applyToCharacter()
end

Features & Information

日本人初のハブスクリプト 1.ユニバーサルガイに多い機能はほぼ搭載 2.座標を入力してテレポートする機能もあるし、めんどくさかったらタッチで座標を登録できる。 3.メモ帳がある(お前何言ってんの?)

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts