I’m trying to make a script in local script where everyone will get transparent except your character but something is not working in this script, I tried to use Test mode : 2 player but it didn’t work
Here’s The Code
local Player = game.Players.LocalPlayer
local StarterGui = game:GetService("StarterGui")
local Players = workspace:WaitForChild("Players")
while true do
wait()
for i,child in pairs(Players:GetChildren()) do
if child:IsA("Model") then
if child.Name ~= Player.Name then
for i,v in pairs(child:GetChildren()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.Transparency = 1
if v.Name == "Head" then
for i, decal in pairs(v:GetChildren()) do
if decal:IsA("Decal") then
decal.Transparency = 1
end
end
end
elseif v:IsA("Tool") or v:IsA("Accessory") then
v:FindFirstChild("Handle").Transparency = 1
end
end
end
end
end
end
You’ll have to modify the .LocalTransparencyModifier property instead, since I’ve last tested, Roblox returns the Transparency to 0 once you change it, in Characters.
while true do
wait()
for i,child in pairs(Players:GetChildren()) do
if child:IsA("Model") then
Instead use this:
while true do
wait()
for i,child in pairs(Players:GetPlayers()) do
if child.Name ~= Player.Name then
A player is "Player" not a "Model"
local Player = game.Players.LocalPlayer
local StarterGui = game:GetService("StarterGui")
local Players = workspace:WaitForChild("Players")
while task.wait() do
for i,player in pairs(Players:GetChildren()) do
local character = player.Character
for i,v in pairs(character:GetChildren()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.Transparency = 1
if v.Name == "Head" then
for i, decal in pairs(v:GetChildren()) do
if decal:IsA("Decal") then
decal.Transparency = 1
end
end
end
elseif v:IsA("Tool") or v:IsA("Accessory") then
v:FindFirstChild("Handle").Transparency = 1
end
end
end
end
local Player = game.Players.LocalPlayer
local StarterGui = game:GetService("StarterGui")
local Players = workspace:GetChildren()
while true do
wait()
for i,child in pairs(Players:GetChildren()) do
if child:IsA("Model") then
if child.Name ~= Player.Name then
if game.Players:FindFirstChild(child.Name) then
for i,v in pairs(child:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("Decal") then
v.Transparency = 1/
elseif v:IsA("Tool") or v:IsA("Accessory") then
v:FindFirstChild("Handle").Transparency = 1
end
end
end
end
end
end
end
I think your problem is that you were waiting in the workspace for Players. With this script, it loops through everything in the workspace and then checks to see if what it has found is a player. If so, it sets the player to become transparent.
Let me know if this doesn’t work though.
In that script I sent, it checks to see if there is a player by looking to see if there is a Player Object with the same name as the child in the workspace. Try that script that I sent, and let me know if it gives you any errors.
Thanks for the responses guy but I found a way to do it.
for i,v in pairs(workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("Humanoid") then
for i, parts in pairs(v:GetChildren()) do
if v:IsA("Part") or v:IsA("MeshPart") do
v.Transparency = 1
end
end
end
end