--!strict local Text = require(game:GetService("ReplicatedStorage"):WaitForChild("Hunter"):WaitForChild("Strings") :: ModuleScript).interface.ViewmodelTuner -- 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 = Text.oruzhie, params = { { name = "OffsetX", label = Text.vpravoVlevo, unit = 1 }, { name = "OffsetY", label = Text.vverkhVniz, unit = 1 }, { name = "OffsetZ", label = Text.vperyodNazad, unit = 1 }, { name = "YawDeg", label = Text.povorotYaw, unit = 20 }, { name = "PitchDeg", label = Text.naklonPitch, unit = 20 }, { name = "RollDeg", label = Text.krenRoll, unit = 20 }, { name = "SwayAmount", label = Text.inertsiya, unit = 4 }, { name = "BobAmount", label = Text.pokachivanie, unit = 0.2 }, }, }, } local function armTab(title: string, prefix: string): Tab return { title = title, params = { { name = prefix .. "HandX", label = Text.kistVpravoVlevo, unit = 1 }, { name = prefix .. "HandY", label = Text.kistVverkhVniz, unit = 1 }, { name = prefix .. "HandZ", label = Text.kistVperyodNazad, unit = 1 }, { name = prefix .. "ArmYawDeg", label = Text.rukaPovorot, unit = 20 }, { name = prefix .. "ArmPitchDeg", label = Text.rukaNaklon, unit = 20 }, { name = prefix .. "ArmRollDeg", label = Text.rukaKren, unit = 20 }, { name = prefix .. "ArmLength", label = Text.dlinaRuki, unit = 2 }, { name = prefix .. "ArmThickness", label = Text.tolschinaRuki, unit = 0.2 }, { name = prefix .. "HandLength", label = Text.dlinaKisti, unit = 0.5 }, { name = prefix .. "HandThickness", label = Text.tolschinaKisti, unit = 0.2 }, }, } end table.insert(TABS, armTab(Text.levayaRuka, "")) table.insert(TABS, armTab(Text.pravayaRuka, "R")) table.insert(TABS, { title = Text.osmotr, buttons = "Inspect", params = { { name = "InspX", label = Text.vpravoVlevo, unit = 1 }, { name = "InspY", label = Text.vverkhVniz, unit = 1 }, { name = "InspZ", label = Text.vperyodNazad, unit = 1 }, { name = "InspYawDeg", label = Text.povorotYaw, unit = 20 }, { name = "InspPitchDeg", label = Text.naklonPitch, unit = 20 }, { name = "InspRollDeg", label = Text.krenRoll, unit = 20 }, { name = "InspDriftDeg", label = Text.dreyfPriUderzhanii, unit = 20 }, { name = "InspBlendIn", label = Text.vykhodVPozuS, unit = 2 }, { name = "InspHold", label = Text.uderzhanieS, unit = 2 }, { name = "InspBlendOut", label = Text.vozvratS, unit = 2 }, }, }) table.insert(TABS, { title = Text.perezaryadka, buttons = "Reload", params = { { name = "ReloadTime", label = Text.dlitelNostS, unit = 2 }, { name = "ReloadPreviewU", label = Text.kadr, unit = 0.2 }, { name = "RlX", label = Text.magazinVpravoVlevo, unit = 1 }, { name = "RlY", label = Text.magazinVverkhVniz, unit = 1 }, { name = "RlZ", label = Text.magazinVperyodNazad, unit = 1 }, { name = "RlYawDeg", label = Text.magazinPovorot, unit = 20 }, { name = "RlPitchDeg", label = Text.magazinNaklon, unit = 20 }, { name = "RlRollDeg", label = Text.magazinKren, unit = 20 }, }, }) -- weapon pose while the bolt is worked (pose B) table.insert(TABS, { title = Text.perezaryadkaZatvor, buttons = "Reload", params = { { name = "RlBX", label = Text.zatvorVpravoVlevo, unit = 1 }, { name = "RlBY", label = Text.zatvorVverkhVniz, unit = 1 }, { name = "RlBZ", label = Text.zatvorVperyodNazad, unit = 1 }, { name = "RlBYawDeg", label = Text.zatvorPovorot, unit = 20 }, { name = "RlBPitchDeg", label = Text.zatvorNaklon, unit = 20 }, { name = "RlBRollDeg", label = Text.zatvorKren, unit = 20 }, { name = "ReloadPreviewU", label = Text.kadr, unit = 0.2 }, }, }) local function reloadHandParams(prefix: string): { Param } return { { name = prefix .. "MagX", label = Text.magazinVpravoVlevo, unit = 1 }, { name = prefix .. "MagY", label = Text.magazinVverkhVniz, unit = 1 }, { name = prefix .. "MagZ", label = Text.magazinVperyodNazad, unit = 1 }, { name = prefix .. "MagDrop", label = Text.magazinVynutVniz, unit = 1 }, { name = prefix .. "BoltX", label = Text.zatvorVpravoVlevo, unit = 1 }, { name = prefix .. "BoltY", label = Text.zatvorVverkhVniz, unit = 1 }, { name = prefix .. "BoltZ", label = Text.zatvorVperyodNazad, unit = 1 }, { name = prefix .. "BoltLift", label = Text.zatvorPodYom, unit = 0.5 }, { name = prefix .. "BoltPull", label = Text.zatvorKhodNazad, unit = 1 }, } end local fpHands = reloadHandParams("") table.insert(fpHands, { name = "MagSizeX", label = Text.magazinTolschina, unit = 0.2 }) table.insert(fpHands, { name = "MagSizeY", label = Text.magazinVysota, unit = 0.5 }) table.insert(fpHands, { name = "MagSizeZ", label = Text.magazinShirina, unit = 0.5 }) table.insert(TABS, { title = Text.perezaryadkaRuki, buttons = "Reload", params = fpHands }) table.insert(TABS, { title = Text.dvizhenie, params = { { name = "MovementWalkSpeed", label = Text.skorostIgrokaStudS, unit = 20 }, { name = "MovementGravity", label = Text.gravitatsiyaStudS, unit = 100 }, { name = "FovBase", label = Text.obzorFov, unit = 20 }, { name = "FovBoost", label = Text.obzorNaBegu, unit = 20 }, { name = "FovSpeed", label = Text.skorostDlyaMaksFov, unit = 20 }, { name = "MoveDipY", label = Text.oruzhieVnizNaBegu, unit = 1 }, { name = "MoveBack", label = Text.oruzhieNazadNaBegu, unit = 1 }, { name = "MoveRollDeg", label = Text.oruzhieKrenNaBegu, unit = 20 }, { name = "MoveLag", label = Text.zapazdyvanie, unit = 0.2 }, { name = "FallLag", label = Text.oruzhiePryzhokPadenie, unit = 0.2 }, }, }) table.insert(TABS, { title = Text.vystrel, buttons = "Shot", params = { { name = "FireInterval", label = Text.mezhduVystrelamiS, unit = 2 }, { name = "MagCapacity", label = Text.patronovVMagazine, unit = 20 }, { name = "ShotZoomPct", label = Text.zumPriOcheredi, unit = 20 }, { name = "SpreadBase", label = Text.spreyNachalNyyUvod, unit = 4 }, { name = "SpreadPerShot", label = Text.spreyRostZaVystrel, unit = 4 }, { name = "SpreadMax", label = Text.spreyPredelRosta, unit = 4 }, { name = "SpreadRecover", label = Text.spreySkorostSbrosa, unit = 20 }, { name = "SpreadAim", label = Text.spreyVPritsele, unit = 1 }, { name = "ShotBoltDelay", label = Text.zatvorPauzaS, unit = 1 }, { name = "ShotBoltTime", label = Text.zatvorSAvtomat, unit = 1 }, { name = "ShotBoltTilt", label = Text.zatvorNaklon2, unit = 1 }, { name = "ShotPreviewT", label = Text.kadrSPosleVystrela, unit = 1 }, }, }) table.insert(TABS, { title = Text.vystrelStvol, buttons = "Shot", params = { { name = "MuzzleX", label = Text.duloVpravoVlevo, unit = 1 }, { name = "MuzzleY", label = Text.duloVverkhVniz, unit = 1 }, { name = "MuzzleZ", label = Text.duloVperyodNazad, unit = 1 }, { name = "FlashSize", label = Text.vspyshkaRazmer, unit = 1 }, { name = "TPMuzzleX", label = Text.lDuloVpravoVlevo, unit = 1 }, { name = "TPMuzzleY", label = Text.lDuloVverkhVniz, unit = 1 }, { name = "TPMuzzleZ", label = Text.lDuloVperyodNazad, unit = 1 }, { name = "TPFlashSize", label = Text.lVspyshkaRazmer, unit = 1 }, { name = "TPRecoilBack", label = Text.lOtdachaNazad, unit = 1 }, { name = "TPRecoilPitchDeg", label = Text.lOtdachaVverkh, unit = 20 }, }, }) -- aiming down the sights: one tab "Прицеливание", a page per sight inside it (attributes Aim...) for _, s in { { "Iron", Text.mushka }, { "RedDot", Text.kollimator }, { "Scope", Text.optika } } do local p = "Aim" .. s[1] table.insert(TABS, { title = s[2], group = Text.pritsel, buttons = "Aim", sight = s[1], params = { { name = p .. "X", label = Text.vpravoVlevo, unit = 1 }, { name = p .. "Y", label = Text.vverkhVniz, unit = 1 }, { name = p .. "Z", label = Text.vperyodNazad, unit = 1 }, { name = p .. "YawDeg", label = Text.povorotYaw, unit = 20 }, { name = p .. "PitchDeg", label = Text.naklonPitch, unit = 20 }, { name = p .. "RollDeg", label = Text.krenRoll, unit = 20 }, { name = p .. "Fov", label = Text.fovZumMenShe, unit = 20 }, { name = p .. "Sens", label = Text.chuvstvitelNostMyshi, unit = 1 }, { name = "AimTime", label = Text.vremyaPritselivaniyaS, unit = 1 }, { name = "AimSway", label = Text.pokachivanieVPritsele, unit = 1 }, { name = "AimSlow", label = Text.zamedlenieVPritsele, unit = 1 }, }, }) end -- mouse sensitivity: from the hip and through each sight (1 = the player's own setting) table.insert(TABS, { title = Text.chuvstvitelNost, params = { { name = "HipSens", label = Text.otBedra, unit = 1 }, { name = "AimIronSens", label = Text.mushka, unit = 1 }, { name = "AimRedDotSens", label = Text.kollimator, unit = 1 }, { name = "AimScopeSens", label = Text.optika, unit = 1 }, }, }) -- sound volumes, the blast on hits, the damage numbers table.insert(TABS, { title = Text.zvukIPopadaniya, params = { { name = "VolMaster", label = Text.gromkostObschaya, unit = 1 }, { name = "VolShot", label = Text.gromkostVystrel, unit = 1 }, { name = "VolReload", label = Text.gromkostPerezaryadkaZatvor, unit = 1 }, { name = "VolHit", label = Text.gromkostPopadanie, unit = 1 }, { name = "VolKill", label = Text.gromkostRazrushenie, unit = 1 }, { name = "HitFxSize", label = Text.razmerVzryvaPriPopadanii, unit = 1 }, { name = "DmgNumSpread", label = Text.tsifryUronaRazlyotV, unit = 1 }, { name = "DmgNumRise", label = Text.tsifryUronaPodYom, unit = 1 }, { name = "KillPopRise", label = Text.ubiystvoVysotaVyleta, 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 .. Text.vpravoVlevo2, unit = 1 }, { name = prefix .. "Y", label = what .. Text.vverkhVniz2, unit = 1 }, { name = prefix .. "Z", label = what .. Text.vperyodNazad2, unit = 1 }, { name = prefix .. "YawDeg", label = what .. Text.povorot, unit = 20 }, { name = prefix .. "PitchDeg", label = what .. Text.naklon, unit = 20 }, { name = prefix .. "RollDeg", label = what .. Text.kren, unit = 20 }, } end table.insert(TABS, { title = Text.lOruzhie, params = poseParams("TPGun", Text.oruzhie) }) for _, side in { { "R", Text.lPravayaRuka }, { "L", Text.lLevayaRuka } } do local params = poseParams("TP" .. side[1] .. "Hand", Text.kist) table.insert(params, { name = "TP" .. side[1] .. "ElbowX", label = Text.lokotVpravoVlevo, unit = 1 }) table.insert(params, { name = "TP" .. side[1] .. "ElbowY", label = Text.lokotVverkhVniz, unit = 1 }) table.insert(params, { name = "TP" .. side[1] .. "ElbowZ", label = Text.lokotVperyodNazad, unit = 1 }) table.insert(TABS, { title = side[2], params = params }) end table.insert(TABS, { title = Text.lPerezaryadka, 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, Text.nastroykaPZakryt, 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 Text.vidELitso else Text.vidELitso2 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 == Text.dvizhenie then label(page, Text.menSheGravitatsiyaVyshe, 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 Text.pritselitSya else Text.proigrat, 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 Text.derzhatPozu elseif kind == "Aim" then Text.derzhatPritsel else Text.derzhatKadr 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 = Text.shag .. tostring(STEPS[stepIndex]) end refreshStep() stepButton.MouseButton1Click:Connect(function() stepIndex = stepIndex % #STEPS + 1 refreshStep() end) local reset = button(panel, Text.sbros, 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, Text.sokhranit, 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 = Text.sokhraneno task.delay(1.5, function() save.Text = Text.sokhranit 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)