본문 바로가기

Roblox Script

#14 : 닿으면 체력이 떨어지는 블록

블록에 닿을 때 체력이 줄어듭니다.
아주 간단하지만, 사실 모든 것의 기본입니다

local box = script.Parent

local function onTouched(hit)
 print ("Touched")

 local humanoid = hit.Parent:FindFirstChild('Humanoid')
 if humanoid then
  print(humanoid.health)
  humanoid:TakeDamage(10)
 end 
end

box.Touched:Connect(onTouched)