I wanted this getpartsinpart loop to get all the parts inside a sphere and turn their transparency to 1 if they’re of a character’s.
local chr = plr.Character
local remotevent = game.ReplicatedStorage.RemoteEvents.Suke.Invisible
local hum = chr:FindFirstChildOfClass("Humanoid")
local health = hum.Health
local Sphere = script.Sphere:Clone()
Sphere.Parent = workspace.Effects
Sphere.Position = chr.HumanoidRootPart.Position
Sphere.Size = Vector3.new(50.75, 50.75, 50.75)
local ended = false
local touched = game.Workspace:GetPartsInPart(Sphere)
local tabletargets = {}
for i, touch in pairs(touched) do
if touch.Parent:FindFirstChildOfClass("Humanoid") then
local chr = touch.Parent
if not table.find(tabletargets, chr) then
for i, c in pairs(chr:GetDescendants()) do
if (c.Name ~= "HumanoidRootPart" and c:IsA("BasePart") or c:IsA("Decal") and c.Name ~= "HumanoidRootPart") then
c.Transparency = 1
if c:IsA("BasePart") then
c.Material = Enum.Material.Glass
end
elseif c:IsA("BillboardGui") then
c.Enabled = false
end
end
wait(1)
table.insert(tabletargets, chr)
print("NPCed LOL noob")
wait(10)
for i, c in pairs(chr:GetDescendants()) do
if (c.Name ~= "HumanoidRootPart" and c:IsA("BasePart") or c:IsA("Decal") and c.Name ~= "HumanoidRootPart") then
if c:IsA("BasePart") then
c.Material = Enum.Material.SmoothPlastic
end
c.Transparency = 0
elseif c:IsA("BillboardGui") then
c.Enabled = true
end
end
end
end
end
The problem is, if I’m in the sphere with an NPC then it’ll set my transparency first and then the NPC’s.
See for yourself: https://gyazo.com/de2993e326b7aea1d3db0dfd4e09b8e7
10 seconds later: