--!strict -- Viewmodel tuning mode (Studio playtests only). Press P to open the panel and adjust the weapon's -- position relative to the camera live: -/+ buttons (hold to repeat) or type a value. -- "Сохранить" hands the values to the ViewmodelTuneSaver Studio plugin, which writes them into the -- attributes of StarterPlayerScripts.SniperViewmodel once the playtest stops (also printed to Output). local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local HttpService = game:GetService("HttpService") if not RunService:IsStudio() then return end local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) local TOGGLE_KEY = Enum.KeyCode.P local player = Players.LocalPlayer local target = player:WaitForChild("PlayerScripts"):WaitForChild("SniperViewmodel") local movementRemote = ReplicatedStorage:WaitForChild("MovementTune") :: RemoteEvent local movementRanges: {[string]: {min: number, max: number}} = { MovementWalkSpeed = {min = 1, max = 80}, MovementGravity = {min = 40, max = 400}, } type Param = { name: string, label: string, unit: number } -- buttons: "Inspect" / "Reload" / "Shot" / "Aim" adds a row with "▶ Проиграть" and a hold toggle; -- sight: for "Aim" tabs, which sight the buttons put on the rifle and aim through -- group: tabs of one group share a single button in the tab bar; their pages get a selector row type Tab = { title: string, params: { Param }, buttons: string?, sight: string?, group: string? } local TABS: { Tab } = { { title = "Оружие", params = { { name = "OffsetX", label = "Вправо / влево", unit = 1 }, { name = "OffsetY", label = "Вверх / вниз", unit = 1 }, { name = "OffsetZ", label = "Вперёд / назад", unit = 1 }, { name = "YawDeg", label = "Поворот (yaw)", unit = 20 }, { name = "PitchDeg", label = "Наклон (pitch)", unit = 20 }, { name = "RollDeg", label = "Крен (roll)", unit = 20 }, { name = "SwayAmount", label = "Инерция", unit = 4 }, { name = "BobAmount", label = "Покачивание", unit = 0.2 }, }, }, } local function armTab(title: string, prefix: string): Tab return { title = title, params = { { name = prefix .. "HandX", label = "Кисть: вправо/влево", unit = 1 }, { name = prefix .. "HandY", label = "Кисть: вверх/вниз", unit = 1 }, { name = prefix .. "HandZ", label = "Кисть: вперёд/назад", unit = 1 }, { name = prefix .. "ArmYawDeg", label = "Рука: поворот", unit = 20 }, { name = prefix .. "ArmPitchDeg", label = "Рука: наклон", unit = 20 }, { name = prefix .. "ArmRollDeg", label = "Рука: крен", unit = 20 }, { name = prefix .. "ArmLength", label = "Длина руки", unit = 2 }, { name = prefix .. "ArmThickness", label = "Толщина руки", unit = 0.2 }, { name = prefix .. "HandLength", label = "Длина кисти", unit = 0.5 }, { name = prefix .. "HandThickness", label = "Толщина кисти", unit = 0.2 }, }, } end table.insert(TABS, armTab("Левая рука", "")) table.insert(TABS, armTab("Правая рука", "R")) table.insert(TABS, { title = "Осмотр", buttons = "Inspect", params = { { name = "InspX", label = "Вправо / влево", unit = 1 }, { name = "InspY", label = "Вверх / вниз", unit = 1 }, { name = "InspZ", label = "Вперёд / назад", unit = 1 }, { name = "InspYawDeg", label = "Поворот (yaw)", unit = 20 }, { name = "InspPitchDeg", label = "Наклон (pitch)", unit = 20 }, { name = "InspRollDeg", label = "Крен (roll)", unit = 20 }, { name = "InspDriftDeg", label = "Дрейф при удержании", unit = 20 }, { name = "InspBlendIn", label = "Выход в позу, с", unit = 2 }, { name = "InspHold", label = "Удержание, с", unit = 2 }, { name = "InspBlendOut", label = "Возврат, с", unit = 2 }, }, }) table.insert(TABS, { title = "Перезарядка", buttons = "Reload", params = { { name = "ReloadTime", label = "Длительность, с", unit = 2 }, { name = "ReloadPreviewU", label = "Кадр (0–1)", unit = 0.2 }, { name = "RlX", label = "Магазин: вправо/влево", unit = 1 }, { name = "RlY", label = "Магазин: вверх/вниз", unit = 1 }, { name = "RlZ", label = "Магазин: вперёд/назад", unit = 1 }, { name = "RlYawDeg", label = "Магазин: поворот", unit = 20 }, { name = "RlPitchDeg", label = "Магазин: наклон", unit = 20 }, { name = "RlRollDeg", label = "Магазин: крен", unit = 20 }, }, }) -- weapon pose while the bolt is worked (pose B) table.insert(TABS, { title = "Перезарядка: затвор", buttons = "Reload", params = { { name = "RlBX", label = "Затвор: вправо/влево", unit = 1 }, { name = "RlBY", label = "Затвор: вверх/вниз", unit = 1 }, { name = "RlBZ", label = "Затвор: вперёд/назад", unit = 1 }, { name = "RlBYawDeg", label = "Затвор: поворот", unit = 20 }, { name = "RlBPitchDeg", label = "Затвор: наклон", unit = 20 }, { name = "RlBRollDeg", label = "Затвор: крен", unit = 20 }, { name = "ReloadPreviewU", label = "Кадр (0–1)", unit = 0.2 }, }, }) local function reloadHandParams(prefix: string): { Param } return { { name = prefix .. "MagX", label = "Магазин: вправо/влево", unit = 1 }, { name = prefix .. "MagY", label = "Магазин: вверх/вниз", unit = 1 }, { name = prefix .. "MagZ", label = "Магазин: вперёд/назад", unit = 1 }, { name = prefix .. "MagDrop", label = "Магазин: вынуть вниз", unit = 1 }, { name = prefix .. "BoltX", label = "Затвор: вправо/влево", unit = 1 }, { name = prefix .. "BoltY", label = "Затвор: вверх/вниз", unit = 1 }, { name = prefix .. "BoltZ", label = "Затвор: вперёд/назад", unit = 1 }, { name = prefix .. "BoltLift", label = "Затвор: подъём", unit = 0.5 }, { name = prefix .. "BoltPull", label = "Затвор: ход назад", unit = 1 }, } end local fpHands = reloadHandParams("") table.insert(fpHands, { name = "MagSizeX", label = "Магазин: толщина", unit = 0.2 }) table.insert(fpHands, { name = "MagSizeY", label = "Магазин: высота", unit = 0.5 }) table.insert(fpHands, { name = "MagSizeZ", label = "Магазин: ширина", unit = 0.5 }) table.insert(TABS, { title = "Перезарядка: руки", buttons = "Reload", params = fpHands }) table.insert(TABS, { title = "Движение", params = { { name = "MovementWalkSpeed", label = "Скорость игрока, студ/с", unit = 20 }, { name = "MovementGravity", label = "Гравитация, студ/с²", unit = 100 }, { name = "FovBase", label = "Обзор (FOV)", unit = 20 }, { name = "FovBoost", label = "Обзор: + на бегу", unit = 20 }, { name = "FovSpeed", label = "Скорость для макс. FOV", unit = 20 }, { name = "MoveDipY", label = "Оружие: вниз на бегу", unit = 1 }, { name = "MoveBack", label = "Оружие: назад на бегу", unit = 1 }, { name = "MoveRollDeg", label = "Оружие: крен на бегу", unit = 20 }, { name = "MoveLag", label = "Запаздывание", unit = 0.2 }, { name = "FallLag", label = "Оружие: прыжок / падение", unit = 0.2 }, }, }) table.insert(TABS, { title = "Выстрел", buttons = "Shot", params = { { name = "FireInterval", label = "Между выстрелами, с", unit = 2 }, { name = "MagCapacity", label = "Патронов в магазине", unit = 20 }, { name = "ShotZoomPct", label = "Зум при очереди, %", unit = 20 }, { name = "SpreadBase", label = "Спрей: начальный увод, °", unit = 4 }, { name = "SpreadPerShot", label = "Спрей: рост за выстрел, °", unit = 4 }, { name = "SpreadMax", label = "Спрей: предел роста, °", unit = 4 }, { name = "SpreadRecover", label = "Спрей: скорость сброса", unit = 20 }, { name = "SpreadAim", label = "Спрей в прицеле, ×", unit = 1 }, { name = "ShotBoltDelay", label = "Затвор: пауза, с", unit = 1 }, { name = "ShotBoltTime", label = "Затвор, с (0 = автомат)", unit = 1 }, { name = "ShotBoltTilt", label = "Затвор: наклон (0–1)", unit = 1 }, { name = "ShotPreviewT", label = "Кадр, с после выстрела", unit = 1 }, }, }) table.insert(TABS, { title = "Выстрел: ствол", buttons = "Shot", params = { { name = "MuzzleX", label = "Дуло: вправо/влево", unit = 1 }, { name = "MuzzleY", label = "Дуло: вверх/вниз", unit = 1 }, { name = "MuzzleZ", label = "Дуло: вперёд/назад", unit = 1 }, { name = "FlashSize", label = "Вспышка: размер", unit = 1 }, { name = "TPMuzzleX", label = "3л дуло: вправо/влево", unit = 1 }, { name = "TPMuzzleY", label = "3л дуло: вверх/вниз", unit = 1 }, { name = "TPMuzzleZ", label = "3л дуло: вперёд/назад", unit = 1 }, { name = "TPFlashSize", label = "3л вспышка: размер", unit = 1 }, { name = "TPRecoilBack", label = "3л отдача: назад", unit = 1 }, { name = "TPRecoilPitchDeg", label = "3л отдача: вверх", unit = 20 }, }, }) -- aiming down the sights: one tab "Прицеливание", a page per sight inside it (attributes Aim...) for _, s in { { "Iron", "Мушка" }, { "RedDot", "Коллиматор" }, { "Scope", "Оптика" } } do local p = "Aim" .. s[1] table.insert(TABS, { title = s[2], group = "Прицел", buttons = "Aim", sight = s[1], params = { { name = p .. "X", label = "Вправо / влево", unit = 1 }, { name = p .. "Y", label = "Вверх / вниз", unit = 1 }, { name = p .. "Z", label = "Вперёд / назад", unit = 1 }, { name = p .. "YawDeg", label = "Поворот (yaw)", unit = 20 }, { name = p .. "PitchDeg", label = "Наклон (pitch)", unit = 20 }, { name = p .. "RollDeg", label = "Крен (roll)", unit = 20 }, { name = p .. "Fov", label = "FOV / зум (меньше = ближе)", unit = 20 }, { name = p .. "Sens", label = "Чувствительность мыши", unit = 1 }, { name = "AimTime", label = "Время прицеливания, с", unit = 1 }, { name = "AimSway", label = "Покачивание в прицеле", unit = 1 }, { name = "AimSlow", label = "Замедление в прицеле (0–1)", unit = 1 }, }, }) end -- mouse sensitivity: from the hip and through each sight (1 = the player's own setting) table.insert(TABS, { title = "Чувствительность", params = { { name = "HipSens", label = "От бедра", unit = 1 }, { name = "AimIronSens", label = "Мушка", unit = 1 }, { name = "AimRedDotSens", label = "Коллиматор", unit = 1 }, { name = "AimScopeSens", label = "Оптика", unit = 1 }, }, }) -- sound volumes, the blast on hits, the damage numbers table.insert(TABS, { title = "Звук и попадания", params = { { name = "VolMaster", label = "Громкость: общая", unit = 1 }, { name = "VolShot", label = "Громкость: выстрел", unit = 1 }, { name = "VolReload", label = "Громкость: перезарядка/затвор", unit = 1 }, { name = "VolHit", label = "Громкость: попадание", unit = 1 }, { name = "VolKill", label = "Громкость: разрушение", unit = 1 }, { name = "HitFxSize", label = "Размер взрыва при попадании", unit = 1 }, { name = "DmgNumSpread", label = "Цифры урона: разлёт в стороны", unit = 1 }, { name = "DmgNumRise", label = "Цифры урона: подъём вверх", unit = 1 }, { name = "KillPopRise", label = "Убийство: высота вылета", unit = 1 }, }, }) -- third person (what other players see): ThirdPersonRifle reads these local function poseParams(prefix: string, what: string): { Param } return { { name = prefix .. "X", label = what .. ": вправо/влево", unit = 1 }, { name = prefix .. "Y", label = what .. ": вверх/вниз", unit = 1 }, { name = prefix .. "Z", label = what .. ": вперёд/назад", unit = 1 }, { name = prefix .. "YawDeg", label = what .. ": поворот", unit = 20 }, { name = prefix .. "PitchDeg", label = what .. ": наклон", unit = 20 }, { name = prefix .. "RollDeg", label = what .. ": крен", unit = 20 }, } end table.insert(TABS, { title = "3л: оружие", params = poseParams("TPGun", "Оружие") }) for _, side in { { "R", "3л: правая рука" }, { "L", "3л: левая рука" } } do local params = poseParams("TP" .. side[1] .. "Hand", "Кисть") table.insert(params, { name = "TP" .. side[1] .. "ElbowX", label = "Локоть: вправо/влево", unit = 1 }) table.insert(params, { name = "TP" .. side[1] .. "ElbowY", label = "Локоть: вверх/вниз", unit = 1 }) table.insert(params, { name = "TP" .. side[1] .. "ElbowZ", label = "Локоть: вперёд/назад", unit = 1 }) table.insert(TABS, { title = side[2], params = params }) end table.insert(TABS, { title = "3л: перезарядка", buttons = "Reload", params = reloadHandParams("TP") }) local TABS_PER_ROW = 4 local PARAMS: { Param } = {} local maxRows = 0 local barCount = 0 -- buttons in the tab bar: one per tab, one per group local seenGroups: { [string]: boolean } = {} for _, tab in TABS do for _, p in tab.params do table.insert(PARAMS, p) end maxRows = math.max(maxRows, #tab.params + (if tab.buttons then 1 else 0) + (if tab.group then 1 else 0)) local group = tab.group if not group or not seenGroups[group] then barCount += 1 end if group then seenGroups[group] = true end end local STEPS = { 0.01, 0.05, 0.2 } local stepIndex = 2 -- the viewmodel script creates its attributes on start; wait so "Сброс" has real values local function missing(): boolean for _, p in PARAMS do if target:GetAttribute(p.name) == nil then return true end end return false end local waited = 0 while missing() and waited < 10 do waited += task.wait(0.1) end local initial: { [string]: number } = {} for _, p in PARAMS do initial[p.name] = (target:GetAttribute(p.name) :: number?) or 0 end local function round(v: number): number return math.floor(v * 1000 + 0.5) / 1000 end -- ---------------------------------------------------------------- UI local gui = Instance.new("ScreenGui") gui.Name = "ViewmodelTuner" gui.ResetOnSpawn = false gui.DisplayOrder = 50 gui.Enabled = false gui.Parent = player:WaitForChild("PlayerGui") local panel = Instance.new("Frame") local ROWS_TOP = 34 + math.ceil(barCount / TABS_PER_ROW) * 30 -- title + tab bar panel.Size = UDim2.fromOffset(330, ROWS_TOP + maxRows * 34 + 46) panel.Position = UDim2.new(0, 16, 0.5, 0) panel.AnchorPoint = Vector2.new(0, 0.5) panel.BackgroundColor3 = Color3.fromRGB(20, 22, 28) panel.BackgroundTransparency = 0.15 panel.Parent = gui Instance.new("UICorner", panel).CornerRadius = UDim.new(0, 8) local function label(parent: Instance, text: string, pos: UDim2, size: UDim2, align: Enum.TextXAlignment?): TextLabel local l = Instance.new("TextLabel") l.BackgroundTransparency = 1 l.Text = text l.Font = Enum.Font.GothamMedium l.TextScaled = true -- long labels shrink instead of running under the buttons local limit = Instance.new("UITextSizeConstraint") limit.MaxTextSize = 14 limit.Parent = l l.TextColor3 = Color3.fromRGB(230, 232, 238) l.TextXAlignment = align or Enum.TextXAlignment.Left l.Position = pos l.Size = size l.Parent = parent return l end local function button(parent: Instance, text: string, pos: UDim2, size: UDim2): TextButton local b = Instance.new("TextButton") b.Text = text b.Font = Enum.Font.GothamBold b.TextSize = 14 b.TextColor3 = Color3.new(1, 1, 1) b.BackgroundColor3 = Color3.fromRGB(55, 60, 75) b.Position = pos b.Size = size b.Parent = parent Instance.new("UICorner", b).CornerRadius = UDim.new(0, 5) UI.bindButton(b, UI.Blue, true) return b end label(panel, "Настройка (P — закрыть)", UDim2.fromOffset(12, 6), UDim2.new(1, -124, 0, 22)) -- switches the local camera between first person and a third-person view of the character local viewButton = button(panel, "", UDim2.fromOffset(214, 5), UDim2.fromOffset(96, 22)) viewButton.TextSize = 12 local function refreshView() local on = target:GetAttribute("ThirdPersonView") == true viewButton.Text = if on then "Вид: 3-е лицо" else "Вид: 1-е лицо" viewButton.BackgroundColor3 = if on then Color3.fromRGB(70, 110, 190) else Color3.fromRGB(55, 60, 75) end viewButton.MouseButton1Click:Connect(function() target:SetAttribute("ThirdPersonView", not (target:GetAttribute("ThirdPersonView") == true)) end) target:GetAttributeChangedSignal("ThirdPersonView"):Connect(refreshView) refreshView() -- Modal button keeps the mouse free while the panel is open in first person. local modal = Instance.new("TextButton") modal.Modal = true modal.BackgroundTransparency = 1 modal.Text = "" modal.Size = UDim2.fromOffset(0, 0) modal.Parent = panel local boxes: { [string]: { TextBox } } = {} -- a value may sit on several tabs local function setValue(name: string, v: number) if v ~= v or math.abs(v) == math.huge then v = (target:GetAttribute(name) :: number?) or initial[name] end local range = movementRanges[name] if range then v = math.clamp(v, range.min, range.max) end v = round(v) if target:GetAttribute(name) ~= v then target:SetAttribute(name, v) if range then movementRemote:FireServer(name, v) end end for _, box in boxes[name] or {} do if not box:IsFocused() then box.Text = tostring(v) end end end local function nudge(p: Param, dir: number) local v = (target:GetAttribute(p.name) :: number?) or 0 setValue(p.name, v + dir * STEPS[stepIndex] * p.unit) end local function holdRepeat(b: TextButton, fn: () -> ()) local holding = false b.MouseButton1Down:Connect(function() holding = true fn() task.delay(0.35, function() while holding do fn() task.wait(0.05) end end) end) b.MouseButton1Up:Connect(function() holding = false end) b.MouseLeave:Connect(function() holding = false end) end -- tabs: a button bar plus one page of rows per tab local ON_COLOR = Color3.fromRGB(70, 110, 190) local OFF_COLOR = Color3.fromRGB(55, 60, 75) local pages: { Frame } = {} local tabButtons: { TextButton } = {} -- by tab index; the tabs of a group share their group's button local subButtons: { { index: number, button: TextButton } } = {} -- selector rows inside groups local groupChoice: { [string]: number } = {} -- last page opened in each group local function selectTab(index: number) local group = TABS[index].group if group then groupChoice[group] = index end for i, page in pages do page.Visible = i == index local on = i == index or (group ~= nil and TABS[i].group == group) tabButtons[i].BackgroundColor3 = if on then ON_COLOR else OFF_COLOR end for _, sub in subButtons do sub.button.BackgroundColor3 = if sub.index == index then ON_COLOR else OFF_COLOR end -- holding the aim while switching sight pages: aim through the newly chosen sight local sight = TABS[index].sight if sight and target:GetAttribute("AimPreview") == true then target:SetAttribute("AimPreviewSight", sight) end end local function addRow(page: Frame, p: Param, y: number) label(page, p.label, UDim2.fromOffset(12, y + 4), UDim2.fromOffset(136, 22)) local minus = button(page, "−", UDim2.fromOffset(150, y), UDim2.fromOffset(30, 28)) local box = Instance.new("TextBox") box.Font = Enum.Font.Code box.TextSize = 14 box.TextColor3 = Color3.new(1, 1, 1) box.BackgroundColor3 = Color3.fromRGB(35, 38, 48) box.ClearTextOnFocus = false box.Position = UDim2.fromOffset(184, y) box.Size = UDim2.fromOffset(92, 28) box.Text = tostring(round((target:GetAttribute(p.name) :: number?) or 0)) box.Parent = page Instance.new("UICorner", box).CornerRadius = UDim.new(0, 5) boxes[p.name] = boxes[p.name] or {} table.insert(boxes[p.name], box) local plus = button(page, "+", UDim2.fromOffset(280, y), UDim2.fromOffset(30, 28)) holdRepeat(minus, function() nudge(p, -1) end) holdRepeat(plus, function() nudge(p, 1) end) box.FocusLost:Connect(function() local v = tonumber((box.Text:gsub(",", "."))) if v then setValue(p.name, v) else box.Text = tostring(round((target:GetAttribute(p.name) :: number?) or 0)) end end) end local tabWidth = math.floor((306 - (TABS_PER_ROW - 1) * 4) / TABS_PER_ROW) local barIndex = 0 local groupButtons: { [string]: TextButton } = {} for i, tab in TABS do local group = tab.group local b: TextButton? = if group then groupButtons[group] else nil if not b then local col, row = barIndex % TABS_PER_ROW, barIndex // TABS_PER_ROW barIndex += 1 local nb = button(panel, group or tab.title, UDim2.fromOffset(12 + col * (tabWidth + 4), 30 + row * 30), UDim2.fromOffset(tabWidth, 26)) nb.TextScaled = true -- four tabs: long titles shrink to fit local fit = Instance.new("UITextSizeConstraint") fit.MaxTextSize = 13 fit.Parent = nb local pad = Instance.new("UIPadding") pad.PaddingLeft = UDim.new(0, 3) pad.PaddingRight = UDim.new(0, 3) pad.Parent = nb nb.MouseButton1Click:Connect(function() selectTab(if group then groupChoice[group] or i else i) end) if group then groupButtons[group] = nb end b = nb end tabButtons[i] = b :: TextButton local page = Instance.new("Frame") page.Name = tab.title page.BackgroundTransparency = 1 page.Position = UDim2.fromOffset(0, ROWS_TOP) page.Size = UDim2.new(1, 0, 0, maxRows * 34) page.Parent = panel pages[i] = page local top = 0 if group then -- selector row: one button per page of the group local members = {} for j, t in TABS do if t.group == group then table.insert(members, j) end end local w = math.floor((298 - (#members - 1) * 4) / #members) for k, j in members do local sb = button(page, TABS[j].title, UDim2.fromOffset(12 + (k - 1) * (w + 4), 0), UDim2.fromOffset(w, 28)) sb.TextSize = 13 sb.MouseButton1Click:Connect(function() selectTab(j) end) table.insert(subButtons, { index = j, button = sb }) end top = 34 end for r, p in tab.params do addRow(page, p, top + (r - 1) * 34) end if tab.title == "Движение" then label(page, "Меньше гравитация — выше прыжок", UDim2.fromOffset(12, top + #tab.params * 34), UDim2.fromOffset(298, 24)) end local kind = tab.buttons if kind then -- InspectPreview/InspectTrigger or ReloadPreview/ReloadTrigger on SniperViewmodel local previewAttr, triggerAttr = kind .. "Preview", kind .. "Trigger" local y = top + #tab.params * 34 local sight = tab.sight local play = button(page, if kind == "Aim" then "▶ Прицелиться" else "▶ Проиграть", UDim2.fromOffset(12, y), UDim2.fromOffset(145, 28)) play.MouseButton1Click:Connect(function() if sight then target:SetAttribute("AimPreviewSight", sight) -- SniperViewmodel puts this sight on the rifle end target:SetAttribute(previewAttr, false) target:SetAttribute(triggerAttr, os.clock()) end) local holdText = if kind == "Inspect" then "Держать позу" elseif kind == "Aim" then "Держать прицел" else "Держать кадр" local holdPose = button(page, holdText, UDim2.fromOffset(165, y), UDim2.fromOffset(145, 28)) local function refreshHold() local on = target:GetAttribute(previewAttr) == true and (not sight or target:GetAttribute("AimPreviewSight") == sight) holdPose.BackgroundColor3 = if on then ON_COLOR else OFF_COLOR end holdPose.MouseButton1Click:Connect(function() if sight and target:GetAttribute("AimPreviewSight") ~= sight then -- another sight's tab was holding: switch the held sight, stay aimed target:SetAttribute("AimPreviewSight", sight) target:SetAttribute(previewAttr, true) return end target:SetAttribute(previewAttr, not (target:GetAttribute(previewAttr) == true)) end) target:GetAttributeChangedSignal(previewAttr):Connect(refreshHold) -- several tabs share it target:GetAttributeChangedSignal("AimPreviewSight"):Connect(refreshHold) refreshHold() end end selectTab(1) local bottom = ROWS_TOP + maxRows * 34 + 6 local stepButton = button(panel, "", UDim2.fromOffset(12, bottom), UDim2.fromOffset(96, 30)) local function refreshStep() stepButton.Text = "Шаг: " .. tostring(STEPS[stepIndex]) end refreshStep() stepButton.MouseButton1Click:Connect(function() stepIndex = stepIndex % #STEPS + 1 refreshStep() end) local reset = button(panel, "Сброс", UDim2.fromOffset(114, bottom), UDim2.fromOffset(80, 30)) reset.MouseButton1Click:Connect(function() for _, p in PARAMS do setValue(p.name, initial[p.name]) end end) local save = button(panel, "Сохранить", UDim2.fromOffset(200, bottom), UDim2.fromOffset(110, 30)) save.BackgroundColor3 = Color3.fromRGB(40, 140, 80) save.MouseButton1Click:Connect(function() local values = {} for _, p in PARAMS do values[p.name] = target:GetAttribute(p.name) end local json = HttpService:JSONEncode(values) print("VIEWMODEL_TUNE " .. json) -- picked up by the ViewmodelTuneSaver Studio plugin and written into the place after the playtest target:SetAttribute("SavedTune", HttpService:JSONEncode({ t = DateTime.now().UnixTimestampMillis, values = values })) save.Text = "Сохранено ✓" task.delay(1.5, function() save.Text = "Сохранить" end) end) local function toggle() gui.Enabled = not gui.Enabled if not gui.Enabled then target:SetAttribute("InspectPreview", false) -- never leave the weapon frozen in the inspect pose target:SetAttribute("ReloadPreview", false) target:SetAttribute("ShotPreview", false) target:SetAttribute("AimPreview", false) target:SetAttribute("ThirdPersonView", false) -- back to the game's first-person camera end if gui.Enabled then for name, list in boxes do for _, box in list do box.Text = tostring(round((target:GetAttribute(name) :: number?) or 0)) end end end end UserInputService.InputBegan:Connect(function(input, processed) if input.KeyCode == TOGGLE_KEY and not UserInputService:GetFocusedTextBox() then toggle() end end)