Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How could i make the model destroy when transparency is 1?

Asked by 6 years ago

Title is self explanatory

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        Character.Archivable = true
        while wait(0.1) do
                spawn(function()
                local clonedCharacter = Character:Clone()
                clonedCharacter.Parent = game.Workspace
                local HumanoidRootPart = clonedCharacter:FindFirstChild("HumanoidRootPart")
                local Humanoid = clonedCharacter:FindFirstChild("Humanoid")
                if HumanoidRootPart then
                    HumanoidRootPart:Destroy()
                end
                if Humanoid then
                    Humanoid:Destroy()
                end
                local Parts = clonedCharacter:GetDescendants()
                for i = 0, 10 do
                    for _, v in pairs(Parts) do
                        if v:IsA("BasePart") then
                          v.Transparency = .5+(.5/10*i)
                          v.CanCollide = false
                          v.Anchored = true
                          v.BrickColor = BrickColor.new("Really black")
                      end
                  end
                  wait(0.1)
                end
            end)
        end
    end)
end)

Answer this question