Why does FilterDescendantsInstances not update properly?

I think I understand why this ISN’T working but I don’t know how to fix it (at least in a performative way)

all I’m trying to do is just make objects in front of the player’s camera transparent, but this only works for one part and any parts behind it don’t turn transparent


sorry if this doesn’t illustrate my issue well

this is done via a local script if that changes anything

-- services
local runservice = game:GetService("RunService")
local tweenservice = game:GetService("TweenService")

-- objects
local cam = workspace.CurrentCamera

local coregameplay = workspace:WaitForChild("CoreGameplay")
local chr = script.Parent
local root = chr.HumanoidRootPart

-- constant
local hiddenstuff = {}

local grocerList = RaycastParams.new()
grocerList.FilterDescendantsInstances = {coregameplay, hiddenstuff}
grocerList.FilterType = Enum.RaycastFilterType.Exclude

local infostuffWahWah = TweenInfo.new(.35,Enum.EasingStyle.Quint)

runservice.Heartbeat:Connect(function()
	local camCf = cam.CFrame
	local ray = workspace:Raycast(camCf.Position,(root.Position-camCf.Position).Unit*100,grocerList)
	
	local hit
	if ray then
		if ray.Instance.Parent ~= chr then
			hit = ray.Instance
			if hit.Transparency == 0 then
				tweenservice:Create(hit,infostuffWahWah,{Transparency = 0.5}):Play()
				table.insert(hiddenstuff,ray.Instance)
			end
		end
	end
	
	for i,v in pairs(hiddenstuff) do
		if hit ~= v then
			if v.Transparency == 0.5 then
				tweenservice:Create(v,infostuffWahWah,{Transparency = 0}):Play()
				table.remove(hiddenstuff, i)
			end
		end
	end
end)

You just need to reupdate the filter descendants instances list to the parts during the heartbeat

1 Like

I’ve tried that and it does seem to work but now it will turn the part transparent, then the one behind it, and then make the part visible again. im wondering how i could mend this cause i can’t really think of too much

I fixed it by debugging and finding a better way with this post Camera Obscuring Help
no rays were needed apparently ^^

if anyone has any better solutions though feel free to post them

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.