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

How do I fix my player invisibility script? (Unanswered)

Asked by 4 years ago
Edited 4 years ago

Hi, I have a script that is supposed to make all players in the table to become invisible but it won't work, there are no errors in the output whenever I run the script.

local plrs = {}

for i, player in pairs(game.Players:GetPlayers()) do
    if player then
        table.insert(plrs, player) 
    end
end

wait()

function setTransparency(char, value)
    for _, child in pairs(char:GetChildren()) do
        if child:IsA('Accessory') then
            local handle = child:FindFirstChild("Handle")
            handle.Transparency = 1
        elseif child:IsA('BasePart') and child.name ~= "HumanoidRootPart" then
            child.Transparency = 1
        end
    end
end

for i, player in pairs(plrs) do
    if player then
    local char = player.Character
    if char then
        local head = char:FindFirstChild("Head")
        local face = head:FindFirstChild("face")
        if enabled and head and game.Players:GetPlayerFromCharacter(char) then
            enabled = false
            for t = 0, 1, 1 do
                if face then face.Transparency = t end
                setTransparency(char, t)
                wait()
                end
            wait()
            enabled = true
        end
    end
end
end

Answer this question