From c18dfc4d56e4dfb395ec037a8ddb796df5006b24 Mon Sep 17 00:00:00 2001 From: min Date: Tue, 9 Jun 2026 17:17:03 +0300 Subject: [PATCH] =?UTF-8?q?fix(g4):=20=D0=BF=D0=BE=D0=B4=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=D0=BA=D0=B0=20[E]=20=D0=B2=D0=B8=D0=B4=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=B2=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B4=D0=B8=D1=83=D1=81=D0=B5=204=20=D0=BE=D1=82=20=D0=BA?= =?UTF-8?q?=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Heartbeat проверяет расстояние от игрока до кнопки. Управляем видимостью через label.Visible (BillboardGui в shim не управляет видимостью children, label.Visible работает напрямую через gui.update). --- src/community/docsGamesBuildersLua.js | 43 +++++++++++++-------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index 340c733..c5cefd8 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -296,11 +296,14 @@ end)`, -- Висит на красной кнопке. Реагирует на E когда игрок рядом. local UserInputService = game:GetService("UserInputService") local TweenService = game:GetService("TweenService") +local RunService = game:GetService("RunService") local part = script.Parent local opened = false +local hintVisible = false --- Подсказка [E] всегда висит над кнопкой пока не открыта +-- Подсказка над кнопкой. BillboardGui в shim — generic instance, +-- управляем видимостью через label.Visible. local hintGui = Instance.new("BillboardGui", part) hintGui.Size = UDim2.new(4, 0, 1, 0) hintGui.StudsOffset = Vector3.new(0, 2, 0) @@ -312,48 +315,44 @@ label.TextColor3 = Color3.fromRGB(255, 255, 255) label.TextStrokeTransparency = 0 label.TextScaled = true label.Text = "[E] Открыть дверь" +label.Visible = false -- скрыт по умолчанию local clickSound = Instance.new("Sound", part) clickSound.SoundId = "click"; clickSound.Volume = 0.8 -UserInputService.InputBegan:Connect(function(input, gp) - if gp then return end +-- Каждый кадр проверяем расстояние до игрока. Подсказку показываем +-- только если игрок в радиусе 4 единиц. +RunService.Heartbeat:Connect(function() if opened then return end - if input.KeyCode ~= Enum.KeyCode.E then return end - - -- Проверяем что игрок рядом с кнопкой (читаем позицию только сейчас, - -- НЕ каждый кадр — это надёжнее) local px = __rbxl_player_x() local pz = __rbxl_player_z() local dx = part.Position.X - px local dz = part.Position.Z - pz local dist = math.sqrt(dx*dx + dz*dz) - if dist > 4 then return end -- слишком далеко + local near = dist <= 4 + if near ~= hintVisible then + hintVisible = near + label.Visible = near + end +end) + +UserInputService.InputBegan:Connect(function(input, gp) + if gp then return end + if opened or not hintVisible then return end + if input.KeyCode ~= Enum.KeyCode.E then return end opened = true hintGui:Destroy() clickSound:Play() __rbxl_show_text("Дверь открывается!", 2) - part.Color = Color3.fromRGB(100, 255, 100) -- зелёная + part.Color = Color3.fromRGB(100, 255, 100) - -- Находим дверь по имени и поднимаем её - print("[g4] looking for door...") local door = workspace:FindFirstChild("Дверь") - print("[g4] door=", tostring(door)) - if not door then - -- Перебираем всех children и пишем имена для отладки - for i, child in ipairs(workspace:GetChildren()) do - print("[g4] child", i, "name=", child.Name) - end - end if door then local dp = door.Position - print("[g4] door pos=", dp.X, dp.Y, dp.Z) local goal = { Position = Vector3.new(dp.X, dp.Y + 6, dp.Z) } - local tween = TweenService:Create(door, TweenInfo.new(1.2), goal) - tween:Play() + TweenService:Create(door, TweenInfo.new(1.2), goal):Play() door.CanCollide = false - print("[g4] tween started") end end)`, g4_finish: `-- === Скрипт финиша (Lua) ===