Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- เก็บ DeadPart ที่เป็น Parent ของสคริปต์นี้ไว้ในตัวแปร
- local DeadPart = script.Parent
- -- เมื่อมีส่วนใดของตัวละครมาแตะ DeadPart
- DeadPart.Touched:Connect(function(part)
- -- หาตัวละครจาก Parent ของ part ที่มาแตะ
- local character = part.Parent
- -- หาวัตถุประเภท Humanoid ภายในตัวละคร
- local humanoid = character:FindFirstChildOfClass("Humanoid")
- -- ถ้าหาเจอ Humanoid ในตัวละคร
- if humanoid then
- -- หาผู้เล่นจากตัวละครที่ได้มา
- local player = game.Players:GetPlayerFromCharacter(character)
- -- ถ้าเจอผู้เล่น (หมายถึงตัวละครนี้เป็นของผู้เล่น)
- if player then
- -- ลดค่าพลังชีวิตของ Humanoid ให้เป็น 0 เพื่อทำให้ตัวละครตาย
- humanoid.Health = 0
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement