feat: 50 игр на Lua + импорт Roblox для всех + поддержка Lua в плеере #39
@ -1468,45 +1468,94 @@ end)`,
|
|||||||
// ИГРА 17 — «Ключ от сундука»
|
// ИГРА 17 — «Ключ от сундука»
|
||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
'key-chest': {
|
'key-chest': {
|
||||||
g17_main: `-- === ИГРА «КЛЮЧ ОТ СУНДУКА» (Lua) ===
|
g17_main: `-- === ИГРА «КЛЮЧ И СУНДУК» — главный скрипт (Lua) ===
|
||||||
local Players = game:GetService("Players")
|
${SNIPPET_BROADCAST}
|
||||||
Players.PlayerAdded:Connect(function(player)
|
|
||||||
local stats = Instance.new("Folder", player); stats.Name = "leaderstats"
|
local won = false
|
||||||
local key = Instance.new("BoolValue", stats); key.Name = "Ключ"
|
|
||||||
|
__rbxl_show_text("Найди ключ и открой сундук!", 3)
|
||||||
|
|
||||||
|
local pickupSound = Instance.new("Sound", workspace)
|
||||||
|
pickupSound.SoundId = "pickup"; pickupSound.Volume = 0.8
|
||||||
|
local winSound = Instance.new("Sound", workspace)
|
||||||
|
winSound.SoundId = "win"; winSound.Volume = 1
|
||||||
|
local loseSound = Instance.new("Sound", workspace)
|
||||||
|
loseSound.SoundId = "lose"; loseSound.Volume = 0.6
|
||||||
|
|
||||||
|
-- Определяем итем "Ключ" в инвентаре (показывает иконку в hotbar)
|
||||||
|
__rbxl_inventory_define("key", "Ключ", "#ffd700")
|
||||||
|
|
||||||
|
-- Игрок подобрал ключ
|
||||||
|
local takeEvent = getEvent("TakeKey")
|
||||||
|
takeEvent.Event:Connect(function()
|
||||||
|
__rbxl_inventory_add("key", 1)
|
||||||
|
__rbxl_show_text("Ты нашёл Ключ!", 2)
|
||||||
|
pickupSound:Play()
|
||||||
end)
|
end)
|
||||||
for _, p in ipairs(Players:GetPlayers()) do
|
|
||||||
if not p:FindFirstChild("leaderstats") then
|
-- Игрок пытается открыть сундук
|
||||||
local stats = Instance.new("Folder", p); stats.Name = "leaderstats"
|
local openEvent = getEvent("OpenChest")
|
||||||
local key = Instance.new("BoolValue", stats); key.Name = "Ключ"
|
openEvent.Event:Connect(function()
|
||||||
|
if won then return end
|
||||||
|
if not __rbxl_inventory_has("key") then
|
||||||
|
__rbxl_show_text("Сундук заперт. Сначала найди ключ.", 2)
|
||||||
|
loseSound:Play()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
end
|
won = true
|
||||||
print("Найди ключ и открой сундук!")`,
|
__rbxl_show_text("Победа! Сундук открыт — там сокровище!", 5)
|
||||||
|
winSound:Play()
|
||||||
|
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)`,
|
||||||
g17_key: `-- === Скрипт ключа (Lua) ===
|
g17_key: `-- === Скрипт ключа (Lua) ===
|
||||||
local Players = game:GetService("Players")
|
-- При касании игроком — отправляем событие и удаляем ключ.
|
||||||
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
local part = script.Parent
|
local part = script.Parent
|
||||||
|
local taken = false
|
||||||
|
|
||||||
part.Touched:Connect(function(hit)
|
part.Touched:Connect(function(hit)
|
||||||
local player = Players:GetPlayerFromCharacter(hit.Parent)
|
if taken then return end
|
||||||
if not player then return end
|
local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
|
||||||
local stats = player:FindFirstChild("leaderstats")
|
if not h then return end
|
||||||
if stats and stats:FindFirstChild("Ключ") then
|
taken = true
|
||||||
stats['Ключ'].Value = true
|
local ev = ReplicatedStorage:FindFirstChild("TakeKey")
|
||||||
print("Подобрал ключ!")
|
if ev then ev:Fire() end
|
||||||
part:Destroy()
|
part:Destroy()
|
||||||
end
|
|
||||||
end)`,
|
end)`,
|
||||||
g17_chest: `-- === Скрипт сундука (Lua) ===
|
g17_chest: `-- === Скрипт сундука (Lua) ===
|
||||||
local Players = game:GetService("Players")
|
-- Подойти и нажать E чтобы открыть.
|
||||||
|
local UserInputService = game:GetService("UserInputService")
|
||||||
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
|
local RunService = game:GetService("RunService")
|
||||||
local part = script.Parent
|
local part = script.Parent
|
||||||
part.Touched:Connect(function(hit)
|
local hintVisible = false
|
||||||
local player = Players:GetPlayerFromCharacter(hit.Parent)
|
|
||||||
if not player then return end
|
RunService.Heartbeat:Connect(function()
|
||||||
local stats = player:FindFirstChild("leaderstats")
|
local px = __rbxl_player_x()
|
||||||
if stats and stats['Ключ'] and stats['Ключ'].Value then
|
local pz = __rbxl_player_z()
|
||||||
print("Сундук открыт! ПОБЕДА!")
|
local dx = part.Position.X - px
|
||||||
part.Color = Color3.fromRGB(255, 215, 0)
|
local dz = part.Position.Z - pz
|
||||||
else
|
local dist = math.sqrt(dx*dx + dz*dz)
|
||||||
print("Нужен ключ!")
|
local near = dist <= 4
|
||||||
|
if near ~= hintVisible then
|
||||||
|
hintVisible = near
|
||||||
|
if near then
|
||||||
|
__rbxl_hud_set("g17_chest_hint", "[E] Открыть сундук", 50, 75, "#ffe44a", 20)
|
||||||
|
else
|
||||||
|
__rbxl_hud_set("g17_chest_hint", nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
UserInputService.InputBegan:Connect(function(input, gp)
|
||||||
|
if gp then return end
|
||||||
|
if not hintVisible then return end
|
||||||
|
if input.KeyCode ~= Enum.KeyCode.E then return end
|
||||||
|
local ev = ReplicatedStorage:FindFirstChild("OpenChest")
|
||||||
|
if ev then ev:Fire() end
|
||||||
end)`,
|
end)`,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user