Advertisement
Anukun_Lucifer

DeadPartScript : Roblox

Aug 5th, 2024
163
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | Gaming | 1 0
  1. -- เก็บ DeadPart ที่เป็น Parent ของสคริปต์นี้ไว้ในตัวแปร
  2. local DeadPart = script.Parent
  3.  
  4. -- เมื่อมีส่วนใดของตัวละครมาแตะ DeadPart
  5. DeadPart.Touched:Connect(function(part)
  6.     -- หาตัวละครจาก Parent ของ part ที่มาแตะ
  7.     local character = part.Parent
  8.  
  9.     -- หาวัตถุประเภท Humanoid ภายในตัวละคร
  10.     local humanoid = character:FindFirstChildOfClass("Humanoid")
  11.  
  12.     -- ถ้าหาเจอ Humanoid ในตัวละคร
  13.     if humanoid then
  14.         -- หาผู้เล่นจากตัวละครที่ได้มา
  15.         local player = game.Players:GetPlayerFromCharacter(character)
  16.  
  17.         -- ถ้าเจอผู้เล่น (หมายถึงตัวละครนี้เป็นของผู้เล่น)
  18.         if player then
  19.             -- ลดค่าพลังชีวิตของ Humanoid ให้เป็น 0 เพื่อทำให้ตัวละครตาย
  20.             humanoid.Health = 0
  21.         end
  22.     end
  23. end)
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement