local Chars = {}
for _, Humanoid in ipairs(game.Workspace:GetDescendants()) do
if Humanoid:IsA("Humanoid") then
table.insert(Chars, Humanoid.Parent)
end
end
for i,v in pairs(game.Workspace:GetDescendants()) do
for i,char in pairs(Chars) do
if v:IsA("Part") or v:IsA("Texture") or v:IsA("Decal") or v:IsA("SpawnLocation") then
if v:IsDescendantOf(char) then
else
task.spawn(function()
originTransparency[v] = v.Transparency
game.TweenService:Create(v,TweenInfo.new(0.5),{Transparency = 1}):Play()
end)
end
end
end
end
This will work
local tween = game:GetService("TweenService")
local plrs = game.Players
local function checkifplayer(plrlist,v)
local IsDescendantOfPlayer = false
for _,plr in pairs(plrlist) do
if v:IsDescendantOf(plr.Character) then IsDescendantOfPlayer = true end
end
return IsDescendantOfPlayer
end
local function FadeAllExceptPlayer()
local PlayerTable = plrs:GetPlayers()
for _,v in pairs(workspace:GetDescendants()) do
if (v:IsA("Part") or v:IsA("MeshPart")) and not checkifplayer(PlayerTable,v) then
tween:Create(v,TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Transparency=1}):Play()
end
end
end
task.wait(5)
FadeAllExceptPlayer()
Edit: This will only fade all parts and meshparts considering that’s mainly we use, if you want more you can add more v:IsA(“”)s to the if statement or just do a pcall to check if the part has property “Transparency”, details below:
Check if object has certain property
Intended or not, this just detects if the instance is part of a player character, and not all humanoids.
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(0.5)
local function ApplyTween(instance)
TweenService:Create(instance, Info, {Transparency = 1}):Play()
end
for _, v in workspace:GetDescendants() do
if not v:IsA('BasePart') then
continue
end
local Character = v:FindFirstAncestorWhichIsA('Model')
if not Character then
ApplyTween(v)
continue
end
local Humanoid = Character:FindFirstChildWhichIsA('Humanoid')
if Humanoid then
continue
end
ApplyTween(v)
end
What do you mean by this? I think my script do check if the part or meshpart is a descendant of any player character, though it do ignore npc humanoids
yeah thats my point, the op says that he wants everything to be invinsible, except for things that contain humanoid, not just players
My bad. Also I think you may have to make the meshids of meshparts to “” so it’s actually invisible. Though how to restore them is another thing.
Btw,
I think you missed in pairs? nvm, I never knew that!
Anyways thanks a lot! Have been searching for an effective method to check this.
No, it works fine, I’ve heard that its actually better to not use any iterator functions
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.