local function V()local V=player:DistanceFromCharacter(target.Position)return V>0 and V<=MAX_DISTANCE end local function s()if not(MainFrame.Visible or SelectionFrame.Visible or TopBar.Enabled)and V()then show()else hide()end end local function j()if not IS_CONSOLE then if not(MainFrame.Visible or SelectionFrame.Visible or TopBar.Enabled)and V()then InteractionButton.Visible=true elseif not V()then InteractionButton.Visible=false end end if MainFrame.Visible and not V()then hide()end end

local function inRange()
	local distance = player:DistanceFromCharacter(target.Position)
	return distance > 0 and distance <= MAX_DISTANCE -- Distance should only be 0 when character doesnt exist
end

local function toggleInteraction()
	if ((not (MainFrame.Visible or SelectionFrame.Visible or TopBar.Enabled)) and inRange()) then
		show()
	else
		hide()
	end
end

local function interactionCheck()
	if not IS_CONSOLE then
		if ((not (MainFrame.Visible or SelectionFrame.Visible or TopBar.Enabled)) and inRange()) then
			InteractionButton.Visible = true
		elseif not inRange() then
			InteractionButton.Visible = false
		end
	end
	
	if MainFrame.Visible and not inRange() then
		hide()
	end
end
