Make Your Character Invisible!

How to make your Character Invisible and then visible! Like an ability!

by lnsertYourself

Author Avatar

Introduction

Hello guys! This is going to be a fun tutorial! I had a lot of fun making this in Roblox Studio and I know you will too! So now I am going to show you what I did.

So what will we be making exactly? Well, I was thinking about how there are no tutorials about how to make your character invisible. So… how about we make an invisibility ability! 🤭

Let’s get Started

Insert a Script into ServerScriptService

This is going to be at the top of our script:

local replicatedStorage = game:GetService("ReplicatedStorage")

local clearDescription = Instance.new("HumanoidDescription") -- Our empty HumanoidDescription

local invisibleAbility = Instance.new("RemoteFunction", replicatedStorage)
invisibleAbility.Name = "InvisibleAbility"

local invisibleTime = 5 -- How long our invisibility will last

HumanoidDescription basically has the information of what a character will look like when the HumanoidDescription is applied to the character. In the code above, we are creating a new HumanoidDescription object. We will use this to clear out our character’s current HumanoidDescription (we will look like a black Roblox Rig).

A character’s HumanoidDescription can be retrieved by Humanoid:GetAppliedDescription() and can be applied to a character by Humanoid:ApplyDescription(HumanoidDescription). We will use both of these in this tutorial.

RemoteFunction is an object used for Server-Client and Client-Server communication. The difference between RemoteFunction and RemoteEvent is that RemoteFunctions yields the caller script until the receiver returns something (which can be nothing). We are going to use this device as our cooldown of when our invisible ability can be activated.

So, let’s set up the code that will run when a player invokes our RemoteFunction.

invisibleAbility.OnServerInvoke = function(player)

end

Next, let’s get our essential variables and get our current HumanoidDescription so it can be reapplied after our invisibility effect is over.

invisibleAbility.OnServerInvoke = function(player)
    print("Making",player.Name,"invisible")
    local character = player.Character
    local humanoid = character.Humanoid
    local originalDescription = humanoid:GetAppliedDescription() -- Getting our original appearance


end

Now that we have the information of our character’s appearance saved, we can now apply an empty HumanoidDescription to our character. Remember, this will give us the appearance of a black Roblox Rig. So this will also get rid of our accessories.

So in the meantime while we look like a black Roblox Rig, let’s make all of our body parts transparent.

invisibleAbility.OnServerInvoke = function(player)
    print("Making",player.Name,"invisible")
    local character = player.Character
    local humanoid = character.Humanoid
    local originalDescription = humanoid:GetAppliedDescription() -- Getting our original appearance
    humanoid:ApplyDescription(clearDescription) -- Applying our empty HumanoidDescription
    for _, child in ipairs(character:GetChildren()) do
        if child:IsA("BasePart") then
            child.Transparency = 1 -- Make all of our parts transparent
        end
    end

end

So we’re gotten rid of all our accessories and made all of our body parts invisible. But we’re forgetting something. OUR FACE! Even though we’ve made all of our parts transparent, the face is a decal object on our head and will not be transparent! We can solve this by giving our face decal an empty texture.

So after we've done that, our character will be completely invisible. Nobody can see your character. So now let’s add our activation timer to our code.

invisibleAbility.OnServerInvoke = function(player)
    print("Making",player.Name,"invisible")
    local character = player.Character
    local humanoid = character.Humanoid
    local originalDescription = humanoid:GetAppliedDescription() -- Getting our original appearance
    humanoid:ApplyDescription(clearDescription) -- Applying our empty HumanoidDescription
    for _, child in ipairs(character:GetChildren()) do
        if child:IsA("BasePart") then
            child.Transparency = 1 -- Make all of our parts transparent
        end
    end
    character.Head.face.Texture = "" -- Clearing our face texture
    wait(invisibleTime) -- Wait the duration of our ability

end

And finally, we can set the transparency of our body parts back to normal as well as reapply the description of our original character.

Final ServerScript Code

local replicatedStorage = game:GetService("ReplicatedStorage")

local clearDescription = Instance.new("HumanoidDescription") -- Our empty HumanoidDescription

local invisibleAbility = Instance.new("RemoteFunction", replicatedStorage)
invisibleAbility.Name = "InvisibleAbility"

local invisibleTime = 5 -- How long our invisibility will last
invisibleAbility.OnServerInvoke = function(player)
    print("Making",player.Name,"invisible")
    local character = player.Character
    local humanoid = character.Humanoid
    local originalDescription = humanoid:GetAppliedDescription() -- Getting our original appearance
    humanoid:ApplyDescription(clearDescription) -- Applying our empty HumanoidDescription
    for _, child in ipairs(character:GetChildren()) do
        if child:IsA("BasePart") then
            child.Transparency = 1 -- Make all of our parts transparent
        end
    end
    character.Head.face.Texture = "" -- Clearing our face texture
    wait(invisibleTime) -- Wait the duration of our ability
    print("Back to visible")
    for _, child in ipairs(character:GetChildren()) do
        if child:IsA("BasePart") and child.Name ~= "HumanoidRootPart" then
            child.Transparency = 0 -- Make all parts besides the HumanoidRootPart visible
        end
    end
    humanoid:ApplyDescription(originalDescription) -- Change to our original appearance
end

The LocalScript

So now that we’ve got that set up. We need to activate it for our character. Let’s insert a LocalScript inside of StarterCharacterScripts. We will be using the F key to activate our invisibility.

Why StarterCharacterScripts? Because we want to make sure our character is spawned in before we use our invisibility ability or else our code will error. We also check if our health is above 0 to make sure we're not dead.

local userInputService = game:GetService("UserInputService")

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local debounce = false
userInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
-- Exit if chatting or typing in a TextBox
    if input.KeyCode == Enum.KeyCode.F and humanoid.Health > 0 then
        if not debounce then
            debounce = true
            print("Activate Invisiblity")
            game.ReplicatedStorage.InvisibleAbility:InvokeServer()
            debounce = false
        end
    end
end)

Normally, you would see debounces alongside a wait(). As I said before, when you invoke a RemoteFunction, the script yields until the receiver returns something (can also be nothing). So in our ServerScript, we had a 5 second activation time before turning our character back to normal. And after that happens, the function exits (because there is no more code to execute) and thus our LocalScript will resume running, thus setting our debounce back to false.

I know, it’s pretty cool huh 😅

See it in Action!

img|5x15

You're a Wizard Harry! 🧙

Conclusion

I hope you’ve learned some useful things from this tutorial. I think the biggest takeaway is using the RemoteFunction as a cooldown timer. But what do you think? Leave a comment and let me know! I read all of them! ⭐

Read more tutorials and never stop learning. See you all later! 👋

View in-game to comment, award, and more!