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

How to make all characters turn invisible?

Asked by 4 years ago

I am wondering how to make all characters in a roblox game turn invisible (via script)? If you can tell me the code that would be great. :) (I am a new developer which is why I don't know this code.)

2 answers

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

You could easily loop through all the characters.

Example of i, v pairs: (looping through all players)

local Players = game.Players.GetPlayers()
for i, v in pairs(Players) do -- looping all players
    print(v.Name) -- all players names
end

Making all players invisible:

local Players = game.Players.GetPlayers() -- all players
for i, v in pairs(Players.Character) do -- looping all characters
    v.Transparency = 1 -- makes  them invisible
end

More information: https://www.lua.org/pil/7.3.html

Ad
Log in to vote
1
Answered by
uhi_o 417 Moderation Voter
4 years ago

This is fairly simple with the pairs loop.

for _, k in pairs(game.Players:GetPlayers()) do
    for _, v in pairs(k.Character:GetChildren()) do
        if v:IsA("Part") or v:IsA("BasePart") then --Making sure it has the transparency property to avoid errors
            v.Transparency = 1
        end
    end
    k.Character.Head.Face.Transparency = 1 --Invisible face
end
0
thank you so much! wolftamer894 50 — 4y

Answer this question