diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index 076bb9f..6cdf886 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -55,41 +55,65 @@ export const LUA_OVERRIDES = { g1_main: `-- === ИГРА «СОБЕРИ МОНЕТКИ» — главный скрипт (Lua) === ${SNIPPET_BROADCAST} +local Players = game:GetService("Players") local score = 0 local TOTAL = 8 --- Создаём leaderstats для отображения счёта в правом верхнем углу -local Players = game:GetService("Players") -Players.PlayerAdded:Connect(function(player) - local stats = Instance.new("Folder", player) - stats.Name = "leaderstats" - local coins = Instance.new("IntValue", stats) - coins.Name = "Монеты" - coins.Value = 0 -end) --- Для уже зашедшего LocalPlayer (Рублокс дублирует PlayerAdded при init): -for _, p in ipairs(Players:GetPlayers()) do - if not p:FindFirstChild("leaderstats") then - local stats = Instance.new("Folder", p) - stats.Name = "leaderstats" - local coins = Instance.new("IntValue", stats); coins.Name = "Монеты" - end -end +-- HUD: счётчик в правом верхнем углу +local player = Players.LocalPlayer +local screenGui = Instance.new("ScreenGui", player.PlayerGui) +screenGui.Name = "CoinHUD" -print("Собери все монетки!") +local label = Instance.new("TextLabel", screenGui) +label.Size = UDim2.new(0, 220, 0, 50) +label.Position = UDim2.new(1, -240, 0, 20) +label.BackgroundColor3 = Color3.fromRGB(0, 0, 0) +label.BackgroundTransparency = 0.4 +label.TextColor3 = Color3.fromRGB(255, 215, 0) +label.TextScaled = true +label.Font = Enum.Font.SourceSansBold +label.Text = "Монеты: 0 / " .. TOTAL +-- Подсказка по центру (на 2 секунды) +local hintGui = Instance.new("ScreenGui", player.PlayerGui) +local hint = Instance.new("TextLabel", hintGui) +hint.Size = UDim2.new(0, 400, 0, 60) +hint.Position = UDim2.new(0.5, -200, 0.3, 0) +hint.BackgroundColor3 = Color3.fromRGB(0, 0, 0) +hint.BackgroundTransparency = 0.4 +hint.TextColor3 = Color3.fromRGB(255, 255, 255) +hint.TextScaled = true +hint.Text = "Собери все монетки!" +task.delay(2, function() hintGui:Destroy() end) + +-- Звуки +local coinSound = Instance.new("Sound", workspace) +coinSound.SoundId = "coin" +coinSound.Volume = 1 + +local winSound = Instance.new("Sound", workspace) +winSound.SoundId = "win" +winSound.Volume = 1 + +-- Подписка на сбор монетки local coinEvent = getEvent("CoinCollected") coinEvent.Event:Connect(function() score = score + 1 - for _, p in ipairs(Players:GetPlayers()) do - local stats = p:FindFirstChild("leaderstats") - if stats and stats:FindFirstChild("Монеты") then - stats['Монеты'].Value = score - end - end - print("Собрано: " .. score) + label.Text = "Монеты: " .. score .. " / " .. TOTAL + coinSound:Play() if score >= TOTAL then - print("Победа! Все монетки твои!") + -- Победный текст + local winGui = Instance.new("ScreenGui", player.PlayerGui) + local winLabel = Instance.new("TextLabel", winGui) + winLabel.Size = UDim2.new(0, 500, 0, 80) + winLabel.Position = UDim2.new(0.5, -250, 0.4, 0) + winLabel.BackgroundColor3 = Color3.fromRGB(0, 100, 0) + winLabel.BackgroundTransparency = 0.2 + winLabel.TextColor3 = Color3.fromRGB(255, 255, 0) + winLabel.TextScaled = true + winLabel.Font = Enum.Font.SourceSansBold + winLabel.Text = "Победа! Все монетки твои!" + winSound:Play() end end)`, // Скрипт каждой монетки — генератор по script-объекту