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) ===