1. ServerScriptService
에 Script
추가

2. Script
이름 HealBlockScript
로 변경

3. HealBlockScript
에 아래 코드 붙여넣기
-- Script by bean7189
--// Functions //--
local function InitializeHealBlocks()
-- Workspace 내 모든 개체 탐색
for _, block: BasePart in pairs(workspace:GetDescendants()) do
-- 탐색한 개체가 BasePart가 아니면 다음 반복 수행
if not (block:IsA('BasePart')) then continue end
-- BasePart의 이름을 '-'로 분리하여 nameTable에 테이블 형태로 저장
local nameTable = string.split(block.Name, '-')
-- 이름 시작 부분이 'Block'이 아니면 다음 반복 수행
local isBlock = nameTable[1] == 'Block'
if not isBlock then continue end
-- 이름 중간 부분이 'Heal'이 아니면 다음 반복 수행
local BlockType = nameTable[2]
if BlockType ~= 'Heal' then continue end
-- 회복 정도를 나타내는 Amount NumberValue를 탐색
local vAmount = block:FindFirstChild('Amount')
-- Amount 탐색에 성공했을 경우 vAmount.Value를 회복량으로, 탐색에 실패했을 경우 10을 회복량으로 설정
local amount = (vAmount and vAmount.Value) and vAmount.Value or 10
-- 회복 쿨타임을 나타내는 CoolTime NumberValue를 탐색
local vCoolTime = block:FindFirstChild('CoolTime')
-- CoolTime 탐색에 성공했을 경우 vCoolTime.Value를 쿨타임으로, 탐색에 실패했을 경우 3을 쿨타임으로 설정
local coolTime = (vCoolTime and vCoolTime.Value) and vCoolTime.Value or 3
local debounce = false
-- 블록 터치 이벤트 연결
block.Touched:Connect(function(coll)
if debounce then return end
debounce = true
;(function()
-- 캐릭터가 정상 상태라 아니라면 회복 작업 수행 안 함
local character = coll.Parent
if not character then return end
local Humanoid = character:FindFirstChildOfClass('Humanoid')
if not Humanoid then return end
-- 터치된 캐릭터의 체력을 회복량 만큼 회복
Humanoid.Health += amount
-- 쿨타임
task.wait(coolTime)
end)()
debounce = false
end)
end
end
----
--// Main //--
-- 모든 Heal 블록 초기화
InitializeHealBlocks()
----
4. Heal 파트 만들기
- Block-Heal: 체력을 회복시킬 캐릭터가 닿는 것을 확인할 블록
- Amount: 캐릭터의 체력을 회복시킬 수 있는 회복량을 의미하는 NumberValue. 속성 창의 Value를 숫자로 지정하여 회복량을 지정할 수 있음.
- CoolTime: 캐릭터가 Block-Heal에 닿아 회복될 때 너무 빠른 회복이 되지 않도록 하는 쿨타임을 의미하는 NumberValue. 속성 창의 Value를 숫자로 지정하여 쿨타임을 초 단위로 지정할 수 있음.

- 완성 모습 (동영상)
