How do you make your bodyparts just fade away when you respawn?
COMMUNITY QUESTION
How do you make your bodyparts fade on respawn?
1 answer
That's the code, I'll comment because it's too long to explain:
local charParts = {} -- We store every player's part here
local player = game.Players.LocalPlayer -- Defining the player value
function addPartToArray()
-- For every part in the player's Character do....
for _, part in pairs (player.Character:GetChildren()) do
-- We don't need to fade non-concrete parts
if tostring(part) == "Humanoid" or tostring(part) == "HumanoidRootPart"
or tostring(part) == "Sound" or tostring(part) == "Animate" then
print("Skipping part" .. " " .. tostring(part))
else
table.insert(charParts, part) -- We insert the parts that we need to fade out
print("Adding part" .. " " .. tostring(part)) -- Just for debugging :P
end
end
end
-- Every 0.01 the transparency of every part in the array "charParts" will fade by "0.1"
function fadeOut()
while true do
for _, part in pairs(charParts) do
part.Transparency = part.Transparency + 0.1
wait(0.01)
end
end
end
-- Since I don't know why in LocalPlayer the ".Death" method doesn't work, I made one on my own :P
function onDeath()
while true do
if player.Character.Humanoid.Health <= 0 then
wait(0.1)
fadeOut() -- I called here the fadeOut function
end
wait(0.2)
end
end
addPartToArray() -- On player's character loads automatically add the parts to the array
onDeath() -- On the death they will fade out ;P
That should work, it has been tested! WARNING: Put this code in a LocalScript INSIDE the STARTERGUI!
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Ok I edited the post!