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)