diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index e3afb6f..5cf12e5 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -278,7 +278,7 @@ end)`; g4_main: `-- === ИГРА «КНОПКА-ОТКРЫВАШКА» — главный скрипт (Lua) === ${SNIPPET_BROADCAST} -__rbxl_show_text("Подойди к красной кнопке и нажми E", 4) +__rbxl_show_text("Наступи на красную кнопку чтобы открыть дверь", 4) local winSound = Instance.new("Sound", workspace) winSound.SoundId = "win"; winSound.Volume = 1 @@ -293,69 +293,35 @@ winEvent.Event:Connect(function() __rbxl_spawn_particles("confetti", px, py + 3, pz, 3, 3) end)`, g4_button: `-- === Скрипт кнопки (Lua) === --- Висит на красной кнопке. Реагирует на E когда игрок рядом. -local UserInputService = game:GetService("UserInputService") +-- Висит на красной кнопке. Срабатывает по касанию игрока (как кнопка-педаль). local Players = game:GetService("Players") -local RunService = game:GetService("RunService") local TweenService = game:GetService("TweenService") local part = script.Parent -local player = Players.LocalPlayer local opened = false -local inRange = false -local hintGui = nil --- Подсказка над кнопкой при подходе -local function showHint() - if hintGui then return end - hintGui = Instance.new("BillboardGui", part) - hintGui.Size = UDim2.new(4, 0, 1, 0) - hintGui.StudsOffset = Vector3.new(0, 2, 0) - hintGui.AlwaysOnTop = true - local label = Instance.new("TextLabel", hintGui) - label.Size = UDim2.new(1, 0, 1, 0) - label.BackgroundTransparency = 1 - label.TextColor3 = Color3.fromRGB(255, 255, 255) - label.TextStrokeTransparency = 0 - label.TextScaled = true - label.Text = "[E] Открыть дверь" -end -local function hideHint() - if hintGui then hintGui:Destroy(); hintGui = nil end -end - --- Каждый кадр проверяем расстояние до игрока -local _debugTick = 0 -RunService.Heartbeat:Connect(function(dt) - if opened 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) - _debugTick = _debugTick + (dt or 0.016) - if _debugTick > 1 then - _debugTick = 0 - print("[g4] px=", px, "pz=", pz, "dist=", dist, "inRange=", inRange) - end - if dist <= 4 and not inRange then - inRange = true - showHint() - elseif dist > 4 and inRange then - inRange = false - hideHint() - end -end) +-- Подсказка над кнопкой +local hintGui = Instance.new("BillboardGui", part) +hintGui.Size = UDim2.new(4, 0, 1, 0) +hintGui.StudsOffset = Vector3.new(0, 2, 0) +hintGui.AlwaysOnTop = true +local label = Instance.new("TextLabel", hintGui) +label.Size = UDim2.new(1, 0, 1, 0) +label.BackgroundTransparency = 1 +label.TextColor3 = Color3.fromRGB(255, 255, 255) +label.TextStrokeTransparency = 0 +label.TextScaled = true +label.Text = "Наступи на кнопку" local clickSound = Instance.new("Sound", part) clickSound.SoundId = "click"; clickSound.Volume = 0.8 -UserInputService.InputBegan:Connect(function(input, gp) - if gp then return end - if opened or not inRange then return end - if input.KeyCode ~= Enum.KeyCode.E then return end +part.Touched:Connect(function(hit) + if opened then return end + local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid") + if not h then return end opened = true - hideHint() + hintGui:Destroy() clickSound:Play() __rbxl_show_text("Дверь открывается!", 2) part.Color = Color3.fromRGB(100, 255, 100) -- зелёная