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

How to make character transparent when they spawn?

Asked by 4 years ago

The goal of this script is to make it so the player is transparent when they spawn but I am not sure where I went wrong. Any help?

local folder = script.Parent
local player = folder.Parent

for index, lookchar in pairs(folder:GetChildren()) do
    if lookchar ~= script then 
        lookchar.Parent = player

        player.Character.Torso.Transparency = 1
        player.Character:FindFirstChild("Left Arm").Transparency = 1
        player.Character:FindFirstChild("Left Leg").Transparency = 1
        player.Character:FindFirstChild("Right Arm").Transparency = 1
        player.Character:FindFirstChild("Right Leg").Transparency = 1
    end
end

2 answers

Log in to vote
1
Answered by 4 years ago

Here, you are just making the parts of the character invisible and not the whole player. I just made a simple script as an example :

game.Players.PlayerAdded:Connect(function(player) -- Calls when the player joins

    local ServerStorage = game:GetService("ServerStorage") 
    local UserId = tostring(player.UserId)

    local FolderExisted = ServerStorage:FindFirstChild(UserId) 

    if not FolderExisted then -- Checks if there is no such folder as the condition
        local Folder = Instance.new("Folder") -- Creates the folder
        Folder.Parent = ServerStorage -- Parents it to ServerStorage
        Folder.Name = UserId -- Name it to the player's UserId
    end 

    -- The next steps will explain why we created this folder

    player.CharacterAdded:Connect(function() -- Calls when the character is added
        repeat wait() until player.Character -- THIS IS VERY IMPORTANT, it would not execute the further code until the whole character is added
        local char = player.Character -- Gets the character
        local charContents = char:GetChildren() -- Creates the table of all contents in the character
        local HeadContents = char:WaitForChild("Head"):GetChildren() -- Creates a table for all contents in the Head of the player

        for i, Mesh in ipairs(charContents) do -- Runs a loop
            if Mesh:IsA("MeshPart") or Mesh:IsA("Part") then -- Checks whether the thing is a MeshPart or a Part
                Mesh.Transparency = 1 -- Sets its Transparency to 1
            end

            if Mesh:IsA("Accessory") then -- Checks whether it is an accessory
                Mesh.Parent = ServerStorage:FindFirstChild(UserId) -- Puts it to the Folder that we created above
            end
        end 

        for i, Decal in ipairs(HeadContents) do 
            if Decal:IsA("Decal") then -- Checks if the content found inside the head is a Decal, here the Decal would be only the Face of the player
                Decal.Transparency = 1 -- Sets its transparency to 1
            end
        end

    end)
end)

Lemme know if it helps!

0
It's a ServerScript in ServerScriptService. If you want to make them visible, just revert the steps BestCreativeBoy 1395 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

So, first, you want to find out if the player is R6 or R15. Then make all body parts Transparent. Place a Script in Workspace and follow my code:

local DefaultTransparency = 1 --Modify if needed
workspace.ChildAdded:Connect(function(Child)
    local h = Child:FindFirstChild("Humanoid")
    if h ~= nil then
        if h.RigType == Enum.RigType.R6 then
            Child.Head.Transparency = DefaultTransparency
            Child.Torso.Transparency = DefaultTransparency
            Child.HumanoidRootPart.Transparency = DefaultTransparency
            Child["Left Arm"].Transparency = DefaultTransparency
            Child["Left Foot"].Transparency = DefaultTransparency
            Child["Right Arm"].Transparency = DefaultTransparency
            Child["Right Foot"].Transparency = DefaultTransparency
        else
            Child.Head.Transparency = DefaultTransparency
            Child.UpperTorso.Transparency = DefaultTransparency
            Child.LowerTorso.Transparency = DefaultTransparency
            Child.LeftFoot.Transparency = DefaultTransparency
            Child.LeftHand.Transparency = DefaultTransparency
            Child.LeftUpperLeg.Transparency = DefaultTransparency
            Child.LeftLowerLeg.Transparency = DefaultTransparency
            Child.LeftUpperArm.Transparency = DefaultTransparency
            Child.LeftLowerArm.Transparency = DefaultTransparency
            Child.RightFoot.Transparency = DefaultTransparency
            Child.RightHand.Transparency = DefaultTransparency
            Child.RightUpperLeg.Transparency = DefaultTransparency
            Child.RightLowerLeg.Transparency = DefaultTransparency
            Child.RightUpperArm.Transparency = DefaultTransparency
            Child.RightLowerArm.Transparency = DefaultTransparency
        end
    end
end)

Hoped this helped!

Answer this question