diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index 2166f9f..646c9a7 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -564,18 +564,66 @@ end)`, // ИГРА 8 — «Беги до финиша» // ═══════════════════════════════════════════════════════════════ 'run-to-finish': { - g8_main: `-- === ИГРА «БЕГИ ДО ФИНИША» — главный скрипт (Lua) === -print("Беги к зелёной плите!")`, - g8_finish: `-- === Финишная плита (Lua) === + g8_main: `-- === ИГРА «БЕГИ К ФИНИШУ» — главный скрипт (Lua) === +${SNIPPET_BROADCAST} + +local Players = game:GetService("Players") +local RunService = game:GetService("RunService") +local player = Players.LocalPlayer +local finished = false +local time = 0 + +__rbxl_show_text("Беги к зелёному финишу — на время!", 3) + +-- Секундомер вверху по центру +local screenGui = Instance.new("ScreenGui", player.PlayerGui) +local timerLabel = Instance.new("TextLabel", screenGui) +timerLabel.Size = UDim2.new(0, 220, 0, 60) +timerLabel.Position = UDim2.new(0.5, -110, 0, 20) +timerLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0) +timerLabel.BackgroundTransparency = 0.4 +timerLabel.TextColor3 = Color3.fromRGB(255, 255, 255) +timerLabel.TextScaled = true +timerLabel.Font = Enum.Font.SourceSansBold +timerLabel.Text = "0.0 сек" + +local winSound = Instance.new("Sound", workspace) +winSound.SoundId = "win"; winSound.Volume = 1 + +-- Каждый кадр прибавляем dt к таймеру +RunService.Heartbeat:Connect(function(dt) + if finished then return end + time = time + (dt or 0.016) + -- Округляем до одного знака для отображения + local rounded = math.floor(time * 10) / 10 + timerLabel.Text = string.format("%.1f сек", rounded) +end) + +-- Финиш-зона шлёт BindableEvent +local finishEvent = getEvent("FinishReached") +finishEvent.Event:Connect(function() + if finished then return end + finished = true + local t = math.floor(time * 10) / 10 + winSound:Play() + __rbxl_show_text("Финиш! Твоё время: " .. string.format("%.1f", t) .. " сек", 6) + local px = __rbxl_player_x() + local py = __rbxl_player_y() + local pz = __rbxl_player_z() + __rbxl_spawn_particles("confetti", px, py + 3, pz, 3, 3) +end)`, + g8_finish: `-- === Скрипт финиша (Lua) === +local ReplicatedStorage = game:GetService("ReplicatedStorage") local part = script.Parent -local won = false +local fired = false + part.Touched:Connect(function(hit) - if won then return end + if fired then return end local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid") if not h then return end - won = true - print("ПОБЕДА! Ты добежал!") - h.WalkSpeed = 0 + fired = true + local ev = ReplicatedStorage:FindFirstChild("FinishReached") + if ev then ev:Fire() end end)`, },