Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script положи внутрь модели NPC
- local TweenService = game:GetService("TweenService")
- local Debris = game:GetService("Debris")
- local npc = script.Parent
- local humanoid = npc:WaitForChild("N1")
- local FADE_TIME = 1 -- время исчезновения
- local DELETE_DELAY = FADE_TIME + 0.1
- local dead = false
- local function fadeObject(obj)
- if obj:IsA("BasePart") then
- obj.CanCollide = false
- obj.CanTouch = false
- obj.CanQuery = false
- local tween = TweenService:Create(
- obj,
- TweenInfo.new(FADE_TIME, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
- { Transparency = 1 }
- )
- tween:Play()
- elseif obj:IsA("Decal") or obj:IsA("Texture") then
- local tween = TweenService:Create(
- obj,
- TweenInfo.new(FADE_TIME, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
- { Transparency = 1 }
- )
- tween:Play()
- end
- end
- humanoid.Died:Connect(function()
- if dead then return end
- dead = true
- for _, obj in ipairs(npc:GetDescendants()) do
- fadeObject(obj)
- end
- Debris:AddItem(npc, DELETE_DELAY)
- end)
Advertisement
Add Comment
Please, Sign In to add comment