feat: 50 игр на Lua + импорт Roblox для всех + поддержка Lua в плеере #39
@ -278,7 +278,7 @@ end)`;
|
|||||||
g4_main: `-- === ИГРА «КНОПКА-ОТКРЫВАШКА» — главный скрипт (Lua) ===
|
g4_main: `-- === ИГРА «КНОПКА-ОТКРЫВАШКА» — главный скрипт (Lua) ===
|
||||||
${SNIPPET_BROADCAST}
|
${SNIPPET_BROADCAST}
|
||||||
|
|
||||||
__rbxl_show_text("Наступи на красную кнопку чтобы открыть дверь", 4)
|
__rbxl_show_text("Подойди к красной кнопке и нажми E", 4)
|
||||||
|
|
||||||
local winSound = Instance.new("Sound", workspace)
|
local winSound = Instance.new("Sound", workspace)
|
||||||
winSound.SoundId = "win"; winSound.Volume = 1
|
winSound.SoundId = "win"; winSound.Volume = 1
|
||||||
@ -293,14 +293,14 @@ winEvent.Event:Connect(function()
|
|||||||
__rbxl_spawn_particles("confetti", px, py + 3, pz, 3, 3)
|
__rbxl_spawn_particles("confetti", px, py + 3, pz, 3, 3)
|
||||||
end)`,
|
end)`,
|
||||||
g4_button: `-- === Скрипт кнопки (Lua) ===
|
g4_button: `-- === Скрипт кнопки (Lua) ===
|
||||||
-- Висит на красной кнопке. Срабатывает по касанию игрока (как кнопка-педаль).
|
-- Висит на красной кнопке. Реагирует на E когда игрок рядом.
|
||||||
local Players = game:GetService("Players")
|
local UserInputService = game:GetService("UserInputService")
|
||||||
local TweenService = game:GetService("TweenService")
|
local TweenService = game:GetService("TweenService")
|
||||||
|
|
||||||
local part = script.Parent
|
local part = script.Parent
|
||||||
local opened = false
|
local opened = false
|
||||||
|
|
||||||
-- Подсказка над кнопкой
|
-- Подсказка [E] всегда висит над кнопкой пока не открыта
|
||||||
local hintGui = Instance.new("BillboardGui", part)
|
local hintGui = Instance.new("BillboardGui", part)
|
||||||
hintGui.Size = UDim2.new(4, 0, 1, 0)
|
hintGui.Size = UDim2.new(4, 0, 1, 0)
|
||||||
hintGui.StudsOffset = Vector3.new(0, 2, 0)
|
hintGui.StudsOffset = Vector3.new(0, 2, 0)
|
||||||
@ -311,15 +311,25 @@ label.BackgroundTransparency = 1
|
|||||||
label.TextColor3 = Color3.fromRGB(255, 255, 255)
|
label.TextColor3 = Color3.fromRGB(255, 255, 255)
|
||||||
label.TextStrokeTransparency = 0
|
label.TextStrokeTransparency = 0
|
||||||
label.TextScaled = true
|
label.TextScaled = true
|
||||||
label.Text = "Наступи на кнопку"
|
label.Text = "[E] Открыть дверь"
|
||||||
|
|
||||||
local clickSound = Instance.new("Sound", part)
|
local clickSound = Instance.new("Sound", part)
|
||||||
clickSound.SoundId = "click"; clickSound.Volume = 0.8
|
clickSound.SoundId = "click"; clickSound.Volume = 0.8
|
||||||
|
|
||||||
part.Touched:Connect(function(hit)
|
UserInputService.InputBegan:Connect(function(input, gp)
|
||||||
|
if gp then return end
|
||||||
if opened then return end
|
if opened then return end
|
||||||
local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
|
if input.KeyCode ~= Enum.KeyCode.E then return end
|
||||||
if not h 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 -- слишком далеко
|
||||||
|
|
||||||
opened = true
|
opened = true
|
||||||
hintGui:Destroy()
|
hintGui:Destroy()
|
||||||
clickSound:Play()
|
clickSound:Play()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user