GetTouchingParts giving me nil but also giving me Instance?

game:GetService("RunService"):BindToRenderStep("ORayPosAndDetect", 294, function()
	local TouchingParts = ORay:GetTouchingParts()
	task.wait()
	ORay.CFrame = Camera.CFrame:ToWorldSpace(CFrame.new(0, 0, -5))
	if not table.find(TouchingParts, CurrentTouchingPart) and CurrentTouchingPart then
		CurrentTouchingPart.BillboardGui.Enabled = false
		CurrentTouchingPart = nil
	end
	
	for i, v in pairs(TouchingParts) do
		if v.Name == "fronticon" then
			v = CurrentTouchingPart
			v.BillboardGui.Enabled = true
		end
	end
end)

The code is meant to show an “interact” icon to open a drawer inside a cabinet, however when I test this out in game it gives me that the instance is nil for some reason
image

But when I print out if the variable is actually nil or instance, it actually gives me the logical results

print(v)
print(v:GetFullName())
print(typeof(v))

image

Do you guys have any idea what’s going on?

My best guess is to make sure that BillboardGui actually exists as a child of the current part it is checking:

There are a number of ways to do this but simplest being in my opinion, add this before trying to use it:

if v:FindFirstChild('BillboardGui') then
1 Like

Nevermind I uhh, I messed up here

v = CurrentTouchingPart

it has to be the opposite, it was making v nil so mb

1 Like