Hasli4

Untitled

Apr 26th, 2026 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. -- Script положи внутрь модели NPC
  2. local TweenService = game:GetService("TweenService")
  3. local Debris = game:GetService("Debris")
  4.  
  5. local npc = script.Parent
  6. local humanoid = npc:WaitForChild("N1")
  7.  
  8. local FADE_TIME = 1 -- время исчезновения
  9. local DELETE_DELAY = FADE_TIME + 0.1
  10.  
  11. local dead = false
  12.  
  13. local function fadeObject(obj)
  14. if obj:IsA("BasePart") then
  15. obj.CanCollide = false
  16. obj.CanTouch = false
  17. obj.CanQuery = false
  18.  
  19. local tween = TweenService:Create(
  20. obj,
  21. TweenInfo.new(FADE_TIME, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  22. { Transparency = 1 }
  23. )
  24. tween:Play()
  25.  
  26. elseif obj:IsA("Decal") or obj:IsA("Texture") then
  27. local tween = TweenService:Create(
  28. obj,
  29. TweenInfo.new(FADE_TIME, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  30. { Transparency = 1 }
  31. )
  32. tween:Play()
  33. end
  34. end
  35.  
  36. humanoid.Died:Connect(function()
  37. if dead then return end
  38. dead = true
  39.  
  40. for _, obj in ipairs(npc:GetDescendants()) do
  41. fadeObject(obj)
  42. end
  43.  
  44. Debris:AddItem(npc, DELETE_DELAY)
  45. end)
Advertisement
Add Comment
Please, Sign In to add comment