Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to get different part names in loop?

the problem is when I am trying this, it doesn't work. I only want the the rest of the body, not head to be invisible. We do a little bit a trolling only head floating... The problem is between v and transparency because I don't know what to put in between to get the loop name so this loop does nothing.

for i, v in pairs(game:GetService("Players"):GetPlayers()) do
            if v ~= LocalPlayer and v:IsA("BasePart") and v.Name ~= "Head" then
                v.Transparency = 1
            end
        end

1 answer

✓ Accepted answer

I didn't fully understand what you were saying, sorry.

Are you trying to make this show up to all players or only to the LocalPlayer?

If for everybody, this is the code (must be in Server):

for i, v in pairs(game:GetService("Players"):GetPlayers()) do
	local character = v.Character or v.CharacterAdded:Wait()
	if character then
		for x, y in pairs(character:GetChildren()) do
			if y:IsA("BasePart") then
				if y.Name ~= "Head" then
					return
				else
					y.Transparency = 1
				end
			end
		end
	end
end

But if for local (yourself) this is the code (must be in Client):

local LocalPlayer = game.Players.LocalPlayer
local char = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
if char then
	for i, v in pairs(char:GetChildren()) do
		if v:IsA("BasePart") then
			if v.Name ~= "Head" then
				return
			else
				v.Transparency = 1
			end
		end
	end
end

But if you want everyone to be invisible but you can only see it, just copy the first one, but put it in a Client script.

Please correct me if there are mistakes. Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.